CraigCav / ko.datasource

Datasource Components for KnockoutJs for paging, sorting and filtering remote sources.
25 stars 10 forks source link

Add additional properties to Pager #3

Closed agrath closed 11 years ago

agrath commented 11 years ago

Add additional computed properties to pager to provide an observable array for the count of pages, a isFirstPage and isLastPage method to control visibility of next/previous and a method to jump to specific page.

Example usage from twitter bootstrap

 <div class="pagination pagination-centered" data-bind="with: items.pager">
        <ul>
            <li data-bind="css: { disabled: isFirstPage }"><a href="#" data-bind="click: previous">Prev</a></li>
            <!-- ko foreach: pages -->
            <li data-bind="css: { active: ($data == $parent.page()) }"><a href="#" data-bind="text: $data, click: $parent.specific"></a></li>
            <!-- /ko -->   
            <li data-bind="css: { disabled: isLastPage }"><a href="#" data-bind="click: next">Next</a></li>
        </ul>
    </div>