On my homepage I have a loop of posts that uses infinite scroll. A user can replace that loop with other loops using ajax like ajax search and so on. My issue is the infinite scroll only works the first time it's used so if it's triggered for the main loop then it won't work again when a new loop replaces the main. Each time a new loop replaces the old the following function is reloaded. So how do I make infinite scroll reset and work every time a new loop is called?
var href = 'first';
$(document).ready(function() {
$('#boxes').infinitescroll({
navSelector: '.infinitescroll',
nextSelector: '.infinitescroll a',
itemSelector: '#boxes .box',
loadingImg: '<?php echo get_bloginfo('stylesheet_directory') ?>/images/loading.gif',
loadingText: 'Loading...',
donetext: 'No more pages to load.',
debug: false
}, function(arrayOfNewElems) {
$('#boxes').masonry('appended', $(arrayOfNewElems));
if(href != $('.infinitescroll a').attr('href')) {
href = $('.infinitescroll a').attr('href');
}
});
});
I'm using the latest version 2.0b2.120519 of the Pual Irish infinite scroll plugin on a wordpress site.