I am using HandlebarsJS and JQuery to display content on a page using the #each helper. What I am trying to achieve is to show few (5) at a time. The data is a JSON file.
sample fiddle here
HTML
<div class="container">
<!-- data goes here -->
</div>
<script id="template" type="text/x-handlebars-template">
<div class="parent">
{{#each names}}
<p class="child">Name: {{name}}, Age: {{age}}. Profession: {{work}}</p>
{{/each}}
</div>
</script>
JS
let model = {
names: [
{name: "Michael", age: 22, work: "apple planter"},
{name: "Smith", age: 35, work: "baseball player"},
{name: "Sally", age: 33, work: "courier"},
{name: "Lara", age: 87, work: "drummer"},
{name: "Simon", age: 25, work: "english teacher"},
{name: "Tucker", age: 27, work: "football player"},
{name: "Angel", age: 87, work: "golf instructor"},
{name: "Venom", age: 44, work: "hotel manager"},
{name: "Clark", age: 82, work: "instructor"},
{name: "Steven", age: 11, work: "junior programmer"},
{name: "Sandy", age: 45, work: "kite designer"},
]
}
let template = Handlebars.compile($("#template").html());
$(".container").html(template(model));
I tried using a $each loop and setTimeout() with a offset variable but that all happens after the page is rendered and slows the page down and its not quite working for me.
Is there a way of doing this with a Helper function in handlebars?
I found this link here but was not very helpful
Any help or suggestions much appreciated.