Skip to content

Instantly share code, notes, and snippets.

@tejasbubane
Created November 19, 2013 10:56
Show Gist options
  • Save tejasbubane/7543689 to your computer and use it in GitHub Desktop.
Save tejasbubane/7543689 to your computer and use it in GitHub Desktop.
This snippet of javascript will convert the will_paginate's default html into the one suitable for bootstrap pagination.
// Just paste this code into the script tag on page and see the will_paginate links applied with pretty bootstrap
// This one is awesome! :)
// PS: Bootstrap required for this to work. Duh!
$(document).ready(function () {
$('.pagination .previous_page').text('«');
$('.pagination .next_page').text('»');
$('.pagination').each(function () {
var $bar = $(this);
$bar.find('a, .current, span').wrapAll('<ul>');
$bar.find('a, .current, span').wrap('<li>');
$bar.find('em').each(function () {
$(this).parent().addClass('disabled');
$(this).replaceWith('<a href="#">' + $(this).text() + '</a>');
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment