bootstrap分頁

前臺界面寫上這個隱藏域
html

<input type="hidden" id="NotReadPage">

js界面bootstrap

初始化方法
app

var pageNumber=1;//設置顯示第幾頁
    if(!isNaN(id)){
        pageNumber=id;
    }
    if(id==(-2)){
        pageNumber=parseInt($("#NotReadPage").val())-1;
    }else if(id==(-1)){
        pageNumber=parseInt($("#NotReadPage").val())+1;
    }

查詢方法接受之爲hashmapurl

url:appPath+'/list',
        data:{pageNumber:pageNumber,pageSize:'5'},
        success:function(data){}
         str+="<div class='dataTables_paginate paging_bootstrap pagination pagination-big'style='text-align:center'>";
            if(pageNumber==1){
                str+="<ul><li class='prev disabled'><a >上一頁</a></li>";
            }else{
                str+="<ul><li class='prev'><a onclick='doQuery("+(-2)+")'>上一頁</a></li>";
            }
            var j=1;
            for(j;j<=size;j++){
                if(j==pageNumber){
                    str+="<li class='active'><a >"+j+"</a></li>";
                }else{
                    str+="<li><a onclick='doQuery("+j+")'>"+j+"</a></li>";
                }
             }
            //若是當只有一頁則都禁止,若是當前頁等於跳的頁則禁止,其餘狀況不由止使用
             if(pageNumber>=size){
                 str+="<li class='next disabled'><a>下一頁</a></li></ul></div></div>";
             }else{
                 str+="<li class='next'><a onclick='doQuery("+(-1)+")'>下一頁</a></li></ul></div></div>";
             }
             $("#NotReadPage").val(pageNumber);
相關文章
相關標籤/搜索