A simple, full-featured, pagination system for jQuery that outputs Twitter Bootstrap marked up pagination links. Of course, there's no reason you need to use this with Bootstrap, the HTML output is very clean.
The library can be used in CoffeeScript, JavaScript, and Rails applications very easily.
Use the src/jquery-bootstrap-pagination.coffee
file.
Use the vendor/assets/javascripts/jquery-bootstrap-pagination.js
file. This file is auto generated from the CoffeeScript file.
Add this line to your application's Gemfile:
gem 'jquery-bootstrap-pagination'
And then execute:
$ bundle
Add it to your application.js
file:
//= require jquery-bootstrap-pagination
# Basic usage:
$("#my-pagination-section").pagination()
# With options:
$("#my-pagination-section").pagination
total_pages: 10
current_page: 2
callback: (event, page) ->
alert("Page #{page} was clicked!")
# Retrieve the underlying PaginationView:
$("#my-pagination-section").data("paginationView")
// Basic usage:
$("#my-pagination-section").pagination();
// With options:
$("#my-pagination-section").pagination({
total_pages: 10,
current_page: 2,
callback: function(event, page) {
return alert("Page " + page + " was clicked!");
}
});
// Retrieve the underlying PaginationView:
$("#my-pagination-section").data("paginationView");
# what is the current page:
current_page: 1
# how many pages are there total:
total_pages: 1
# change text of the 'next' link,
# set to false for no next link:
next: ">"
# change text of the 'previous' link,
# set to false for no previous link:
prev: "<"
# change text of the 'first' link,
# set to false for no first link:
first: false
# change text of the 'last' link,
# set to false for no last link:
last: false
# how many links before truncation happens:
display_max: 8
# render nothing if there is only 1 page:
ignore_single_page: true
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Write/Run tests (
bundle exec rake
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request