Binding to Bootstrap pager component.
<div data-bind="pager: { currentPage: page, totalCount: total, isAligned: aligned, text: text }"></div>
function PagerExampleViewModel() {
this.page = ko.observable(1);
this.total = ko.observable(100);
this.aligned = ko.observable(false);
this.text = {
back: ko.observable('←'),
forward: ko.observable('→')
};
}
All of the options can be observables.
data-bind="pager: { currentPage: page, totalCount: count, pageSize: size, isAligned: aligned, text: textObj }"
currentPage
Type: number, should be observable (default: 1)
Contains selected page.
totalCount
Type: number, can be observable
Contains total count of items, for which paging is used. Used to determine pages amount.
pageSizes
Type: number, can be observable (default: 10)
Specifies amount of items per page. Used to determine pages amount.
isAligned
Type: boolean, can be observable (default: false)
If true, adds next and previous css classes to buttons.
text
Type: object, can be observable
Contains text for back and forward buttons.
Default values of text object:
back
Type: string, can be observable (default: '←')
Contains text for "Back" button
forward
Type: string, can be observable (default: '→')
Contains text for "Forward" button