ノックアウトを使用して Pager コントロールを作成しています。「currentPageIndex」、「itemsPerPage」、「totalRecords」などのプロパティを持つviewModel(PaginatorViewModel)があります。各ページには、ページのTOPに1つ、Bottomにもう1つの2つのページネーションコントロールがあります。
場合によっては、タブがあり、各タブに 2 つのページネーション コントロール (TOP と Bottom) があります。
Tab1 にいて、ページ 2 (currentPageIndex=2) に移動すると、Tab2 のページネーション コントロールも currentPageIndex を 2 として表示します。
すべてのタブで PaginatorViewModel を使用したいのですが、複数のインスタンス、つまりタブごとに 1 つのインスタンスを維持したいと考えています。
どうすればこれを達成できますか。
これが私のViewModelです。
var CustomPaginator = {
//The current page index of the post being displayed.
currentPageIndex: ko.observable(1),
//specifies the page options
pageOptions : ko.observableArray([25, 50, 100, 200]),
//specifies the PageOptions will be shown or not.
showOptions : ko.observable(true),
//The maximum number of topics displayed per page.
itemsPerPage : ko.observable(25),
//Specifies the total no of records
totalRecords : ko.observable(1),
isVisible : ko.observable(false),
//pageIndex is bounded to the text box, and the CurrentPageIndex contains the actual value.
// this is to avoid the notifying the subscribers when the user enters the out of range values
// like 0,and N , where N > no of pages
pageIndex : ko.observable(1)
};
このインスタンスを作成するにはどうすればよいですか。
ありがとう、ラメッシュ