Skip to content

Commit

Permalink
Stopped double fire of trigger when removing deeply nested items.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelcox committed Jun 8, 2012
1 parent 701126d commit 621caf3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions backbone-nested.js
Expand Up @@ -95,13 +95,13 @@

// remove the element from the array
val.splice(i, 1);
opts.silent = true; // Triggers should only be fired in trigger section below
this.set(aryPath, val, opts);

if (trigger){
attrStr = Backbone.NestedModel.createAttrStr(aryPath);
this.trigger('remove:' + attrStr, this, oldEl);
this.trigger('change:' + attrStr, this, oldEl);
for (var aryCount = aryPath.length - 1; aryCount >= 0; aryCount--) {
for (var aryCount = aryPath.length; aryCount >= 1; aryCount--) {
attrStr = Backbone.NestedModel.createAttrStr(_.first(aryPath, aryCount));
this.trigger('change:' + attrStr, this, oldEl);
}
Expand Down

0 comments on commit 621caf3

Please sign in to comment.