基于AJAX的分页类实现代码

2019-09-14 07:17:58王冬梅

        if(this.pageNo == 1) toolbar = toolbar + " 首页 上页";
        else toolbar = toolbar + " <a href='' id='firstPage"+this.id+"'>首页</a> <a href='' id='prePage"+this.id+"'>上页</a>";
        if(this.pageNo == pageCount) toolbar = toolbar + " 下页 末页";
        else toolbar = toolbar + " <a href='' id='nextPage"+this.id+"'>下页</a> <a href='' id='lastPage"+this.id+"'>末页</a>";
        toolbar = toolbar + " 每页<input style='text-align:center;width:25px;height:20px;border:1 solid black' type='text' id='pageSize"+this.id+"' value="+this.pageSize+" />条";
        toolbar = toolbar + " <input style='text-align:center;width:25px;height:20px;border:1 solid black' type='text' id='pageNo"+this.id+"' value="+this.pageNo+" />";
        toolbar = toolbar + " <input style='height:20px;border:1 solid black' id='goPage"+this.id+"' type='button' value='GO'>";
        templatObj.children().html(toolbar);
        $(templatObj.wrap("<div></div>").parent().html()).appendTo($('#tbody_id'+this.id));
        var thisObj = this;
        $('#firstPage'+thisObj.id).click(function(){
            thisObj.pageNo = 1;
            thisObj.load(thisObj.url,thisObj.params);
            return false;
        });
        $('#prePage'+thisObj.id).click(function(){
            thisObj.pageNo = parseInt(thisObj.pageNo) - 1;
            thisObj.load(thisObj.url,thisObj.params);
            return false;
        });
        $('#nextPage'+thisObj.id).click(function(){
            thisObj.pageNo = parseInt(thisObj.pageNo) + 1;
            thisObj.load(thisObj.url,thisObj.params);
            return false;
        });
        $('#lastPage'+thisObj.id).click(function(){