I am using the "Simple custom control to add infinite scrolling to repeat or views" available as snippet on OpenNTF.
This works but incorrect, this is what happens:
When you reach the bottom of screen a pager control gets triggered and an AJAX call is send.
However you are still at the bottom of the screen so again the pager control gets triggered and a second ajax call is send. (check the XHR requests in your browser with firefox or something).
So you requested for 1 additional set of values and get 2 returned.
Sometimes the second ajax request is finished earlier than the first and then the sorting in the repeat control is messed up.
I first tried to set a timeout on the JS call e.g.
$(window).scroll(function() {
if ($(window).scrollTop() == $(document).height() - $(window).height()) {
setTimeout(function() {
$(".infiniteScroll ul li a").click();
}, 4000);
}
});
but I have to set the timeout to a large amount of milliseconds and sometimes 4000 is not sufficient.
I wonder if there is an option to chain the ajax calls for the pager control or disable temporarily the trigger?