I’ve started to use jQuery Templates and I think it’s great.
I am trying to build a pager.
My MVC action returns a JSON object with the current page and the total number of pages.
I would like to create a series of buttons.
I’ve seen I can use {{each}} but it seems that I can only loop in collections.
Is there a way I can loop from currentPage to totalPages and build a series of buttons:
<script id="pagerTmpl" type="text/x-jquery-tmpl">
<input type="radio" id="q_page_" name="radio" /><label for="q_page_">xxx</label>
</script>
I know this code doesn’t work but I would like to achieve something like this:
<script id="pagerTmpl" type="text/x-jquery-tmpl">
{{each(currentPage, totalPages)}}
<input type="radio" id="q_page_" name="radio" /><label for="q_page_">xxx</label>
{{/each}}
</script>
Any help will be apreciated.
This works: