Fixing Issue #109 -- ignore 'add' and 'remove' events that originate from models shared with other collections.

This commit is contained in:
Jeremy Ashkenas
2010-12-02 09:31:55 -05:00
parent 3505bde58e
commit 6a0ac93086
2 changed files with 22 additions and 11 deletions

View File

@@ -564,8 +564,10 @@
// Internal method called every time a model in the set fires an event.
// Sets need to update their indexes when models change ids. All other
// events simply proxy through.
_onModelEvent : function(ev, model) {
// events simply proxy through. "add" and "remove" events that originate
// in other collections are ignored.
_onModelEvent : function(ev, model, collection) {
if ((ev == 'add' || ev == 'remove') && collection != this) return;
if (ev === 'change:id') {
delete this._byId[model.previous('id')];
this._byId[model.id] = model;