Bootstrapページング機能
5393 ワード
function bootstrappage() {
var options = {
currentPage: currentPage,
totalPages: totalPages,
size: 'normal',
itemContainerClass: function (type, page, current) {
return (page === current) ? "active" : "pointer-cursor";
},
itemTexts: function (type, page, current) {
switch (type) {
case "first":
return "First";
case "prev":
return " ";
case "next":
return " ";
case "last":
return "Last";
case "page":
return page;
}
},
shouldShowPage: function (type, page, current) {
switch (type) {
case "first":
case "last":
return false;
default:
return true;
}
},
onPageClicked: function (e, originalEvent, type, page) {
currentPage = page;
zwobj.url = "../../Handler/PostsHandler.ashx?action=GetPosts";
zwobj.data = { current: currentPage, total: 10 };
ajaxData();
}
};
$('#example').bootstrapPaginator(options);
}
//---------------------------- ---------------------------------
function ajax_GetPosts(data) {
$(".table tbody").html("");
var html = "";
var len = data.Data.length;
for (var i = 0; i < len; i++) {
html += "<tr>" +
"<td><a href='#'>" + data.Data[i].Title + "</a></td>" +
"<td>" + eval("new " + data.Data[i].CreateDt.split('/')[1]).Format("yyyy-MM-dd") + "</td>" +
"<td>" + data.Data[i].ReplyCount + "/" + data.Data[i].ViewCount + "</td>" +
"<td>" + data.Data[i].UserName + "</td></tr>";
}
$(".table tbody").html(html);
var total = parseInt(data.Other); totalPages = (total / 10) + 1; bootstrappage();
}