I have a javascript function that takes the total number of items in a list and then divides them based on how many are allowed on a page. I use an array that I populate with a loop based on that number to create my page numbers. This is all for a handlebars template.
My problem is, it doesn't seem like the array is going through the template, but just being put straight into my div, because when inspect the element, there is no anchor tag around either of the numbers
The function:
function GetPages() {
var TotalItems = 10;
var NumOnPage = 9;
var NumPages = Math.ceil(TotalItems / NumOnPage);
console.log(NumPages);
var list = [];
for (var i = 1; i <= NumPages; i++) {
list.push(i);
}
var source = $("#HB-PageTemplate").html();
var template = Handlebars.compile(source);
var html = (list);
$('.Pager').append(html);
}
The Template:
<script id="HB-PageTemplate" type="text/x-handlebars-template">
{{#each list}}
<div><a class="pagelink">{{this}}</a></div>
{{/each}}
</script>
The div:
<div class="Pager"></div>