Skip to content
This repository has been archived by the owner on Jul 4, 2021. It is now read-only.

Reset not setting state back to first page. #293

Open
rsumilang opened this issue Jul 17, 2015 · 7 comments
Open

Reset not setting state back to first page. #293

rsumilang opened this issue Jul 17, 2015 · 7 comments

Comments

@rsumilang
Copy link

Only the models get reset when I call reset. The cursor does not move the state back to the firstPage. Is this by design and is there a recommended way to handle this?

@ambischof
Copy link

I would assume the best way to handle this is to listen to the collection reset event and in the handler do this.collection.state.currentPage = 1; and try to make that happen before your views redraw.

@wyuenho
Copy link
Member

wyuenho commented Oct 2, 2015

Resetting a PageableCollection has the same semantics as resetting a plain Backbone.Collection, it merely clears the data view, no underlying state is changed as a result. Resetting doesn't mean refetch. If you want to refetch, call one of those get* methods.

@jeacott
Copy link

jeacott commented Nov 5, 2015

none of the get* methods reset the links list for infinite mode, so there is currently no practical way to reset state.

@sirianni
Copy link

A common pattern in Backbone apps is to reset a collection vs. re-instantiating it. This allows all the upfront wiring of that collection to views to continue to function properly without losing the reference. Without being belt to use reset properly on PageableCollection, this severely constrains the usage.

@wyuenho wyuenho reopened this Feb 12, 2016
@wyuenho
Copy link
Member

wyuenho commented Feb 12, 2016

I want to understand the usage pattern before I make a change. There are many scenarios when we talk about the constitution of resetting the state. Do you want to reset the state back to when you first instantiated the collection? Reset the current page to the first page? Leave it alone? Or do you foresee that you'll want all of the above at some point?

@sirianni
Copy link

Do you want to reset the state back to when you first instantiated the collection?

This is my use case. I basically instantiate a collection and wire it up to some views. Those views then listen for various events (including reset). I use reset as a means of modifying that collection contents without needing to re-wire all the views. Think of a results page that can be modified by facet selection. I don't want to re-instantiate the results view when the collection contents changes.

@wyuenho
Copy link
Member

wyuenho commented Feb 15, 2016

Are you using PageableCollection as a general substitute for Backbone.Collection? Generally you'd only ever want to reset when paging, for which there are get* methods you can call, or you can call fetch directly.

The only reason I brought up resetting the state back to first instantiation was some people would like to set the current page to, say 3 on instantiation, and for some reason they'd like to reset back to that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants