Reputation: 4993
I want to implement grid paging with pagerjs library. I found how to read parameters from javascript code. With html
<div data-bind="page: { id: 'clients', params: {'page':1}, title: 'Clients', withOnShow: requireVM('clientsList') }">
<div data-bind="template: { name: 'clientsSearch' }" id="clients-list" class="clientsSearch"></div>
</div>
I successfuly bind template and viewmodel. Incide viewmodel I can read value of page parameter with code
pager.activePage$().ctx.page
The page property is observable. I tried to subscribe to it with code
pager.activePage$().ctx.page.subscribe(function (newValue) {
debugger;
});
I made button for navigating to next page
<li data-bind="css: { disabled: isLastPage() }">
<a class="btn" data-bind="page-href: {path: '/start/clients', params: { page: parseInt(currentPage()) + 1 }}"><span class="glyphicon glyphicon-chevron-right"></span></a>
</li>
It changes Url nicely but pager.activePage$().ctx.page.subscribe doesn't actualy fire.
I need some approach to notify viewmodel about parameters changes. How can I accomplish it?
Upvotes: 1
Views: 428