Open Muon opened 10 years ago
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
.
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
Hmm, that's awkward. So what should I do if my data is just... data? Just give them arbitrary different ids?
Setting the same contents fires events even if nothing has changed, see fiddle for example: http://jsfiddle.net/xNWUM/1/