-
-
Save seyhunak/1471973 to your computer and use it in GitHub Desktop.
Kaminari and pushState
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
(function($){ | |
$('.pagination a[data-remote=true]').live('ajax:success', function(e){ window.history.pushState('', '', $(e.target).attr('href')) }) | |
$(window).bind('popstate', function(){ $.ajax({url:window.location, dataType:'script'}) ; return true }); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok I finally have a code up to date on this code
.live is deprecated, .click stops working after first click, since according to kaminari example, they use .html() function which to keep it simple, destroy the event handler. By using on() like this, you recreate the bindings.