$.line={
setLine:function(totalPage,o){
for(var i=0;i
var a=$('< ;a/>').html('' (i 1) '').addClass('pageA').bind('click',function(){
var s=$(this);
s.siblings().removeClass('pageActive')
s.addClass('pageActive')
o.currentPage=s.text(); >$.page.loadData(o)
});
if(o.currentPage==i 1){
a.addClass('pageActive');
}
o.pager.append(a);
}
varlimit=this.getLimit(o,totalPage);
var aPage=o.pager.find('a.pageA').not('a.previous,a.nextAll,a.record');
aPage.hide();
aPage.slice(limit.start,limit.end).show();
var prev=$('').html('上一页').addClass('pageA 이전').unbind('click') .bind('click',function(){
var pageActive=o.pager.find('a.pageActive');
var s=$(this);
if(pageActive.prev( ).text()=='上一页'){
alert('已经是第一页!');
return false;
}
pageActive.removeClass('pageActive') ;
pageActive.prev().addClass('pageActive');
o.currentPage=pageActive.prev().text()
$.page.loadData(o); );
var next=$('').html('下一页').addClass('pageA nextAll').unbind('click') .bind('click',function(){
var pageActive=o.pager.find('a.pageActive');
var s=$(this);
if(pageActive.next( ).text()=='下一页'){
alert('已经是最后一页!')
return false
}
pageActive.removeClass('pageActive') ;
pageActive.next().addClass('pageActive');
o.currentPage=pageActive.next().text()
$.page.loadData(o); );
var pageActiveText=o.pager.find('a.pageActive').text();
var Record=$('').html('' pageActiveText '/' totalPage '').addClass('pageA 레코드');
o.pager.prepend(prev).prepend(record).append(next);
}
}
현재 상면의 현대적인 페이지에서Active类,所以现我们可以实现$.page的getCurrentPage函数,不常简单
p를 반환합니다.
}
接着我们实现生成json数据的genData函数,json格式为{key:value,key:value}
if (!$(form).html() || $(form).html() == null || $.trim($(form).html()) == "") {
널을 반환합니다;
}
var formEl = $(form).find('input[type="text"]');
var formselect = $(form).find('select');
var json = "{";
for (var i = 0; i < formEl.length - 1; i ) {
var name = formEl.eq(i).attr('name');
var val = "'" formEl.eq(i).val() "'";
json = 이름;
json = ":";
json = 발;
json = ",";
}
var lname = formEl.eq(formEl.length - 1).attr('name');
var lval = "'" formEl.eq(formEl.length - 1).val() "'";
json = l이름;
json = ":";
json = lval;
if (formselect) {
json = ",";
for (var i = 0; i < formselect.length - 1; i ) {
var name = formselect.eq(i).attr('name');
var val = "'" formselect.eq(i).val() "'";
json = 이름;
json = ":";
json = 발;
json = ",";
}
var lname = formselect.eq(formselect.length - 1).attr('name');
var lval = "'" formselect.eq(formselect.length - 1).val() "'";
json = l이름;
json = ":";
json = lval;
}
json = "}";
var jsonObj = eval("(" json ")")
return jsonObj;
}
接着我们为查询表单的按钮绑定事件,我们扩話下我们的$.page函数