网学网Ajax编辑为广大网友搜集整理了:基于AJAX的分页类实现代码绩等信息,祝愿广大网友取得需要的信息,参考学习。
复制代码 代码如下:
/**
* <p>pagination.js
* <p>通用的基于AJAX的分页类
* @author jeanwendy
* @version 1.0
*/
var paginationIndex = 0;
var pagination = function(trTemplatId) {
$().ajaxStart(function() {
$.blockUI({
message : ''<table><tr><td style="vertical-align :bottom"><font size=2pt> 加载数据,请稍后...</font></td></tr></table>''
});
}).ajaxStop($.unblockUI);
paginationIndex = paginationIndex + 1;
this.id = paginationIndex;
this.trTemplatId = trTemplatId;
this.pageNo = 1;
this.pageSize = 10;
this.beforeQuery = null;
this.afterQuery = null;
this.url = null;
this.params = null;
this.templat = null;
this.childrenCount = null;
this.setPageNo = function(pageNo) {
if (pageNo != null)
this.pageNo = pageNo;
}
this.setPageSize = function(pageSize) {
if (pageSize != null)
this.pageSize = pageSize;
}
this.setBeforeQuery = function(fn){
this.beforeQuery = fn;
}
this.setAfterQuery = function(fn){
this.afterQuery = fn;
}
this.load = function(url, params) {
//初始化(只在第一次
查询时执行)
if(this.templat == null && this.childrenCount == null){
var templatObj = $(''#''+this.trTemplatId);
templatObj.parent().attr(''id'',''tbody_id''+this.id);
templatObj.removeAttr(''id'');
templatObj.wrap("<div id=''divTemplat''></div>");
this.templat = $(''#divTemplat'').html();
$(''#divTemplat'').remove();
&