复制代码代码如下所示:
* ajax分页功能
*添加到需要分页的地方
*作为分页组件容器元素。
*总页数总页数
* currentpage当前页码
*的分页类OL容器元素的容器
加载数据加载所有功能
* 1版
* /
分页:功能(总页数,currentpage,容器,加载所有){
this.startpage = 1;
this.endpage =总页数;
this.mindisplaypagecount = 5;
var = $(容器);
无功paginationlinks = ;
如果(总页数= = 1){
C.css({ 'visibility:隐藏的});
返回;
}
如果(总页数> this.mindisplaypagecount + 1){
如果(currentpage - this.mindisplaypagecount > 0){
this.startpage = currentpage - this.mindisplaypagecount;
}
如果(((currentpage + this.mindisplaypagecount - 1)<总页数){
this.endpage = currentpage + this.mindisplaypagecount - 1;
{人}
this.endpage =总页数;
}
}
= paginationlinks ;
如果(currentpage!= 1){
paginationlinks = 页上的;
}
对于(var i = this.startpage;i < this.endpage;i++){
如果(currentpage = =我){
paginationlinks + currentpage + + = ;
{人}
PaginationLinks +我+ + = ;
}
}
如果(currentpage <总页数){
paginationlinks = 下一页;
}
= paginationlinks ;
C.html(paginationlinks);
VaR链接=美元(# page_number ul );
links.each(函数(指数){)
如果((this.innerhtml = =!页面上的| | this.innerhtml = =下一页)){
$(this)Click(函数(事件){)
警报(链接{指数}。innerHTML);
加载所有(curtaskid,
分页(总页数,parseInt(链接{指数}。innerHTML),容器,加载所有);
});
}
});
前一页= $(var#前一页);
VaR做=(#美元做);
C.css({ 'visibility:'visible});
如果(前一页){
PrevPage.click(功能(事件){)
加载所有(curtaskid,
分页(总页数,currentpage - 1,容器,加载所有);
});
}
如果(nextpage){
NextPage.click(功能(事件){)
加载所有(curtaskid,
分页(总页数,currentpage + 1,容器,加载所有);
});
}
}
加载所有是加载数据功能,需要定义页面的数量的参数,如:
复制代码代码如下所示:
无功currentpage = 1;
LoadExamList(currentpage){
分页(5,currentpage,$(UL),loadexamlist);
};
5个是总页数,1个是当前页码。$(UL)是页面按钮存储的位置。LoadExamList的功能称为点击前一页的时候,下一页或页号。