I want to do some paging for a list of observables. I use bootstrap for the styling, and in their documentation they use unsorted list to display the links for the pages.
Let's suppose we have the following code in the view:
<ul class="pagination" data-bind="foreach : ko.utils.range(1, 10)">
<li><a href="#" data-bind="text : $data"></a></li>
</ul>
This code will display this:
<ul class="pagination">
<li><a href="#">1</a></li>
<li><a href="#">2</a></li>
...
<li><a href="#">10</a></li>
</ul>
The question : How with knockout can I add static <li>
at the top and the bottom of the unsorted list that will link to previous and next pages? This must be the displayed html:
<ul class="pagination">
<li><a href="#">previous</a></li>
<li><a href="#">1</a></li>
<li><a href="#">2</a></li>
...
<li><a href="#">10</a></li>
<li><a href="#">next</a></li>
</ul>
Thank you.
you can use below syntax..
<ul class="pagination">
<li><a href="#">previous</a></li>
<!-- ko foreach : ko.utils.range(1, 10) -->
<li><a href="#" data-bind="text : $data"></a></li>
<!-- /ko -->
<li><a href="#">next</a></li>
</ul>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With