var keywords = "";
var page = 1;
var pageSize = 3;
var totalPage = 1;
var laypage;
layui.use('laypage', function () {
laypage = layui.laypage;
});
$(function () {
bindListener();
ajaxGetInvitation();
})
function ajaxGetInvitation() {
$.ajax({
url:baseUrl+"api/Invitation",
data: {"method": "queryInvitation", "page": page, "pageSize": pageSize, "keywords": keywords},
type: "get",
dataType: "json",
success: function (jsonData) {
var data = jsonData.data;
readInvitation(data);
renderPager(jsonData.totalCount)
console.log(data)
},
error: function (jsonData) {
}
})
}
// 分页
function renderPager(totalCount) {
laypage.render({
elem: 'pageContainer'
, count: totalCount
, limit: pageSize
, curr: page
, limits: [3, 5, 10, 20, 30, 40, 50]
, layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
, jump: function (obj, first) {
//obj包含了当前分页的所有参数,比如:
console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。
console.log(obj.limit); //得到每页显示的条数
//首次不执行
if (!first) {
//把分页值,和分页量(分页量可能会变化)
page = obj.curr;
pageSize = obj.limit;
ajaxGetInvitation();
}
}
});