[Solved] Endless scroll bug?
-
Even though I correctly run
done()
it keeps on loading endlessly!loadMore(index, done) { // index - called for nth time // done - Function to call when you made all necessary updates. // DO NOT forget to call it otherwise your loading message // will continue to be displayed // make some Ajax call then call done() store.dispatch('fetchDone').then(fetched => { console.log(fetched); if (fetched == 'fetchedAll'){ done(); } })
Also, I wonder what the difference between
done()
andstop()
is. The docs are unclear in that. -
Try done(true). This schould stop endless loading
-
I got this from chatting on Gitter, in case anyone wants to know:
The
stop()
method is used to interrupt loading no matter the scroll position. Thedone()
method should always be called after each ajax request, else the loading message stays
→ on all callbacks?
Yes. It used to define not your fetch is done but to define your REQUEST is done. Always calldone()
at the end of the handler.
So in your case:store.dispatch('fetchDone').then(_ => done());
→ I don’t need to indicate there’s no more data on the server left to fetch?
just save something like
true
towindow.noMoreData
if all data is fetched. Andif (window.noMoreData){ return }
in front of the ajax call in theloadMore
method.