1

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?

Patrick Kwinten
  • 1,988
  • 2
  • 14
  • 26
  • Not easy. The addRows button uses the function "XSP.appendRows". This function can be found in "plugins\com.ibm.xsp.extlib.controls\resources\web\extlib\dijit\DataIterator.js" of the Extension library source code. An option could be to hijack that function. You could probably add an 'disabled' attribute on the node when you click on it and when for example "_parseDojo" or "_count" is called then remove that attribute (these are called after the partial refresh). Then before the .click() function, check if the 'disabled' attribute exist or not. Not the most elegant way... – Ferry Kranenburg Nov 17 '15 at 21:38

1 Answers1

0

I found out the problem lies with the way the infinite scroll is triggered: when reaching the bottom of the window.

Then, no state is set (e.g. loading) so before the results of the first trigger are returned a second or third trigger could be fired.

Patrick Kwinten
  • 1,988
  • 2
  • 14
  • 26