Created
November 19, 2013 10:56
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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