On my homepage, I have a message loop that uses infinite scrolling. The user can replace this loop with other loops using ajax, for example, an ajax search, and so on. My problem is scrolling endlessly, it only works the first time it starts for the main loop, then it won't work again when the new loop replaces the main one. Each time a new cycle replaces the old, the next function is reloaded. So, how do I do an endless 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 am using the latest version 2.0b2.120519 of the Pual Irish infinite scroll plugin on the wordpress site.