Guest User

Untitled

a guest
Jun 21st, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. // AJAX pagination support with will_paginate and jQuery; history fix via jQuery-BBQ
  2.  
  3. baseurl = location.protocol + '//' + location.host + location.pathname;
  4.  
  5. $(function() {
  6. $('.pagination a').live('click', function(e) {
  7. params = $.deparam.querystring(this.href);
  8. new_url = $.param.fragment(baseurl, params, 2);
  9. $(this).parent('.pagination').append("<img src='/images/spinner.gif' class='spinner' />"); // show loading spinner
  10. location.hash = $.param.fragment( new_url ); // set the new hash, which will trigger the hashchange event
  11. return false;
  12. });
  13. });
  14.  
  15. $(window).bind( 'hashchange', function(e) {
  16. params = e.fragment; // pre-jQuery1.4: $.deparam.fragment(document.location.href);
  17. $.getScript( $.param.querystring(baseurl, params) );
  18. });
  19.  
  20. if (location.hash) {
  21. $(window).trigger( 'hashchange' );
  22. }
Add Comment
Please, Sign In to add comment