@H_502_0@推荐阅读:<a target="_blank" href="//www.jb51.cc/article/78733.htm">jQuery插件开发精品教程让你的jQuery提升一个台阶
@H_502_0@既然说到基于jQuery的ajax分页插件,那我们就先看看主要的代码结构:(我觉得对咱们程序员来说再优美的文字描述、介绍也
@H_502_0@比不上代码来得实在。) @H_502_0@ 1、首先定义一个pager对象:
属性
pageSize:,preText: "pre",nextText: "next",firstText: "First",lastText: "Last",shiftingLeft:,shiftingRight:,preLeast:,nextLeast:,showFirst: true,showLast: true,url: "",type: "POST",dataType: "JSON",searchParam: {},beforeSend: null,success: null,complete: null,error: function () {
alert("抱歉,请求出错,请重新请求!");
},},pagerElement: null,//分页dom元素
commonHtmlText: {
//公共文本变量
},init: function (obj,op) {
//对象初始化
},doPage: function (index,pageSize,searchParam) {
//执行分页方法
},getTotalPage: function () {
//获取总页数
},createPreAndFirstBtn: function (pageTextArr) {
//创建上一页、首页按钮链接
},createNextAndLastBtn: function (pageTextArr) {
//创建下一页、尾页按钮链接
},createIndexBtn: function (pageTextArr) {
//中间分页索引按钮链接
},renderHtml: function (pageTextArr) {
//渲染分页控件到页面
},createSpan: function (text,className) {
//创建span
},createIndexText: function (index,text) {
//创建索引文本
},jumpToPage: function () {
//跳转到
}
}
@H_502_0@ 对象包含了分页的属性及用到的方法,doPage()为分页的核心方法。
@H_502_0@ 2、进行jQuery扩展