msjolund/jquery-esn-autobrowse — Issue #1: Missing return in scrollCallback() function
Author: kjfubar
Created: 2011-12-22 14:04:32+00:00
State: open

Thanks for the autobrowse code, it was helpful in developing my scripts. One thing I thought I'd point out, it was driving me nuts, on a fast connection, I would get repetitive "No more data to load" messages, and multiple json requests when running out of data. I noticed the function would call itself again and again, looping until the _stopPlugin function had completed. Simply added a return statement when the **options.itemsReturned(reponse)=0** was true did the trick and eneded the loop.

```javascript
-------------------------
// Check if these were the last items to fetch from the server, if so, stop listening
if (options.itemsReturned(response) == 0 || (options.max != null && options.itemsReturned(response) + currentOffset >= options.max))
{
_stopPlugin(scrollCallback)
--> return; // break and do not call scrollCallBack() again
}
loading = false;
scrollCallback()
};
-----------------------
```