I\'m using the loop + jQuery below to load in the next set of pages, and it works on the first click, but when the next page is loaded in and I click on \"newer posts\" it r
You're using jQuery's load()
method to insert content, which is a shortcut for $.ajax
, which of course inserts the content dynamically.
Dynamic content requires delegation of the events to a non-dynamic parent, something jQuery makes easy with on()
jQuery(function($) {
$('#content').on('click', '#pagination a', function(e){
e.preventDefault();
var link = $(this).attr('href');
$('#content').fadeOut(500, function(){
$(this).load(link + ' #content', function() {
$(this).fadeIn(500);
});
});
});
});