基於bootstrap的分頁外掛程式bootstrap-paginator

來源:互聯網
上載者:User

項目中用到了分頁,花費了些時間才弄完,總結出來,希望能讓大家少走彎路。資料庫是mysql,用到了mysql的limit start,len

首先下載:bootstrap-paginator的js外掛程式,地址:

然後在頁面中:

<div id="pagination" ></div>var options = {        currentPage: 1,//              totalPages :10,                             itemContainerClass: function (type, page, current) {            return (page === current) ? "active" : "pointer-cursor";        },        itemTexts: function (type, page, current) {            switch (type) {            case "first":                return "首頁";            case "prev":                return "前一頁";            case "next":                return "下一頁";            case "last":                return "末頁";            case "page":                return page;            }        },        onPageClicked: function(e,originalEvent,type,page){            e.stopImmediatePropagation();            var currentTarget = $(e.currentTarget);            var pages = currentTarget.bootstrapPaginator("getPages");            // Ajax calling            setTableData(page);            currentTarget.bootstrapPaginator("show",page);            updatePagesInfo($("#totalRecord").val(), page);        },        pageUrl: function(type, page, current){            return "#";        }    };$('#pagination').bootstrapPaginator(options);

options中的數值是可以動態設定的,如要根據查詢條件或去總的記錄數,options.totalPages = 20,

效果如下:


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.