Intro
This jQuery plugin simplifies the usage of Bootstrap Pagintion. It uses appropriate classes:
.pagination (you change this one), .active and .disabled.
Check out the demo.
Click to download:
Download .zip file Download .tar.gz file
Demo
Here is corresponding piece of code:
$('#pagination-demo').twbsPagination({
totalPages: 35,
visiblePages: 7,
onPageClick: function (event, page) {
$('#page-content').text('Page ' + page);
}
});
And HTML code:
<ul id="pagination-demo" class="pagination-sm"></ul>
Options and events
- Options explanation and default values:
totalPagesthe number of pages (required, checked)startPagethe current page that show on start(default: 1)visiblePagesmaximum visible pages (default: 5)hreftemplate for pagination links (defaultfalse)hrefVariablevariable name in href template for page number (default{{number}})firsttext label (default:'First')prevtext label (default:'Previous')nexttext label (default:'Next')lasttext label (default:'Last')loopcarousel-style pagination (default:false)paginationClassthe root style for pagination component (default:'pagination'). You can use this option to apply your own style
- Available event:
onPageClickcallback function- Function parameters
eventobjectpagethe number of page
Examples
URL page link
You can specify url using href option:
$(selector).twbsPagination({
totalPages: 35,
visiblePages: 8,
href: '?page={{number}}'
});
Visible pages option
The max number of visible pages specifies via visiblePages option. The following example
shows the 10 visible pages:
$(selector).twbsPagination({
totalPages: 35,
visiblePages: 10,
});
Note: this is normal size (without pagination-sm)
Synchronized pagination elements
You can attach multiple paginators to your content and access them via class name. The following example show this case.
License
Copyright 2014 Eugene Simakin
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.