webdev-gadgets-bootstrap-pagination

html code

<div class="text-center"> <div class="pagination"></div> </div>

1. simple example

$('.pagination1').bsPagination({ totalRecord: 200, currentPage: 1 });

2. add more config params

$('.pagination2').bsPagination({ totalRecord: 400, currentPage: 15, recordPerPage: 10, pagePerBatch: 10, prevBatchWord: 'Prev', nextBatchWord: 'Next', showFirstPage: true, showLastPage: true, firstPageWord: 'First', lastPageWord: 'Last' });

3. set page link to change page, the url will change when you click page

Infact you can set any attr by setLinkAttr

$('.pagination3').bsPagination({ totalRecord: 200, currentPage: 8, setLinkAttr: function (page) { return 'href="#/page/' + page + '"'; } });

4. set click link event to change page, pagination will change when you click page

$('.pagination4').bsPagination({ totalRecord: 200, currentPage: 18 }); $('.pagination4').on('click', 'a', function () { $('.pagination4').bsPagination({ totalRecord: 200, currentPage: $(this).data('page') }); });

back to github