Last active
November 15, 2017 09:24
-
-
Save landsman/5241030b656c9f25f565 to your computer and use it in GitHub Desktop.
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
// AJAX paging | |
jQuery('.pagination a').live('click', | |
function(e) | |
{ | |
//check when pagination link is clicked and stop its action. | |
e.preventDefault(); | |
var mainWrapper = '#page-content .container'; | |
var mainContent = '#content'; | |
var link = jQuery(this).attr('href'); //Get the href attribute | |
// change browser url | |
window.history.pushState(link, link, link); | |
jQuery(mainWrapper) | |
.fadeOut(500, function() | |
{ | |
//fade out the content area | |
// here is place to load external JS libs to refresh render | |
jQuery(".loader").show(); // show the loader animation | |
} | |
) | |
.load(link + ' ' + mainContent, function() | |
{ | |
jQuery(mainWrapper).fadeIn(500, | |
function() | |
{ | |
//load data from the content area from paginator link page that we just get from the top | |
jQuery(".loader").fadeOut(800); //hide the loader | |
} | |
); | |
} | |
); | |
// move back to header | |
jQuery('html, body').animate({ | |
scrollTop: jQuery('header').offset().top | |
}, 500); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment