Infinite mode triggers "reset" event after fetching each new page
jdudek opened this issue · 18 comments
In infinite mode, calling getNextPage()
results in reset
event on fullCollection
being triggered instead of the add
event. This gist contains a test for this problem: https://gist.github.com/jdudek/2253e3907929945967cc (this is a patch against current git master).
The problems seems to be caused by this line
else if (links[currentPage]) { // refetching a page
where links[currentPage]
is already defined after merging results from parseLinks
.
BTW the infinite mode demo linked in the README does not load.
Triggering add
events from a fetch is a new behavior added to Backbone 1.0. Fixing this properly will break support for older Backbone versions.
I do plan to remove support for Backbone < 1.0, but Backbone 1.0 has a bug that messes up pageable's handling of query parameters. (See #70).
Even if I fix it now, I'm not comfortable enough to release it because I want to require Backbone >1.0.0 in package.json. The Backbone team's been stalling on the next release.
You can help me pester the Backbone team to release 1.0.1 or 1.1.0 or whatever. I'm busy with Backgrid at the moment, so it may take me a couple of days until I can get to this. PR welcome.
@wyuenho thanks for the response. Maybe the docs are a bit misleading now, as they suggest add
event on fullCollection
is the right way to use infinite mode.
@aronitin It took me too much time to figure out this problem, so in the end I decided to write my own, quick extension to collections that adds infinite loading. For now I don't really need most of the other features that Backbone.Pageable provides, so this was easiest path in my case.
@jdudek That used to be case in 1.3.0. I reverted back in 1.3.1 and forgot to update the doc.
@aronitin here it is: https://gist.github.com/jdudek/c67202f5ac59ffee21c3 (I had to edit it slightly, but hopefully didn't break anything).
I am using backbone 1.0 (I cant change that) but i am willing to use backbone-pageable with infinte mode?
Any news on this? or how to make it work?
@josx I did not make any changes to the source code to make it work. You may want to switch to some other open source alternative if you are not too deep in using this library.
I'll commit a fix for this today. There's no other better alternative backbone pagination library out there other than backbone.paginator, which is utterly broken and many ways.
@wyuenho Great! I will be waiting for it.
Backbone.paginator is the best alternative to manage pagination on backbone collections.
+1 also looking forward to the fix! thanks
Ok guys, I have an easy fix but that requires you guys to upgrade to Backbone master. Backbone 1.0.0 broke a lot of things at the last minute before release. Does anyone object to upgrading to Backbone master?
@wyuenho Mind throwing up the fix in a gist if you don't want to commit right away?
👍 I need this too, please :)
Hi @wyuenho , I'd really like to know if there are news on this. I'm ok if that implies using bb master.
Thanks!
hi @wyuenho thanks for the fix, its working great now for getNextPage()
for my purposes however, i still need getFirstPage({fetch:true}) to reset the collection, as i often change sorting on the collection, and then get the first page of results again with the new order. is there perhaps an easy way to force it to do this?
thanks again
Open a new ticket with an outline of the scenario that you'd like pageable to support.