這取決於你如何檢索信息。對onPageClick: function (event, page) {}
事件
var $pagination = $('#pagination');
var totalValue = 25; //for example
var toShow = 20; //show 20 items
var numOfPage = Math.ceil(totalValue/toShow);
if (numOfPage > 1) {
var totalPages = numOfPage;
var currentPage = $pagination.twbsPagination('getCurrentPage');
$pagination.twbsPagination('destroy');
$pagination.twbsPagination($.extend({}, defaultOpts, {
startPage: currentPage,
totalPages: totalPages
}));
} else {
$pagination.twbsPagination('destroy'); //don't show pagination
//if all item on the 1st page
}
UPDATE應先分配下一個Ajax調用,併成功投放提供的代碼:在的情況下,AJAX,叫你能做到這樣,receving結果之後。像這樣的東西。
onPageClick: function (event, page) {
loadNextValues(page); //function to retrieve information.
//most probably you need this assignment -> page = page -/+ 1
//I don't remember exactly
}
這個分頁是懶加載。至少提供算法。