Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Setting same fires remove/add/sort #143

Open
Muon opened this Issue · 3 comments

2 participants

@Muon

Setting the same contents fires events even if nothing has changed, see fiddle for example: http://jsfiddle.net/xNWUM/1/

@Muon Muon changed the title from Setting same fires add/remove/sort to Setting same fires remove/add/sort
@Muon

Hmm, this seems to be tied to the id attribute. Two models seems only seem to be considered same if they have the same id.

@dhruvaray dhruvaray added the question label
@dhruvaray dhruvaray self-assigned this
@dhruvaray
Owner

This is in line with Backbone behavior. We use Backbone's smart set method internally for 1:M relations.(all working on id)

From Backbone documentation

If you want to smartly update the contents of a Collection, adding new models, removing missing ones, and merging those already present, you now call set (previously named "update"), a similar operation to calling set on a Model. This is now the default when you call fetch on a collection. To get the old behavior, pass {reset: true}.

This internally calls add/remove/sort. Search for _addReference, _removeReference in http://backbonejs.org/docs/backbone.html

@Muon

Hmm, that's awkward. So what should I do if my data is just... data? Just give them arbitrary different ids?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.