Merge pull request #1327 from TheBits/silent-merge

Merge model with silent flag
This commit is contained in:
brad dunbar
2012-06-06 04:36:10 -07:00
2 changed files with 9 additions and 6 deletions

View File

@@ -613,12 +613,6 @@
index = options.at != null ? options.at : this.models.length;
splice.apply(this.models, [index, 0].concat(models));
if (this.comparator && options.at == null) this.sort({silent: true});
if (options.silent) return this;
for (i = 0, length = this.models.length; i < length; i++) {
if (!cids[(model = this.models[i]).cid]) continue;
options.index = i;
model.trigger('add', model, this, options);
}
// Merge in duplicate models.
if (options.merge) {
@@ -629,6 +623,13 @@
}
}
if (options.silent) return this;
for (i = 0, length = this.models.length; i < length; i++) {
if (!cids[(model = this.models[i]).cid]) continue;
options.index = i;
model.trigger('add', model, this, options);
}
return this;
},

View File

@@ -158,6 +158,8 @@ $(document).ready(function() {
equal(col.first().get('name'), 'Moe');
col.add({id: 1, name: 'Moses'}, {merge: true});
equal(col.first().get('name'), 'Moses');
col.add({id: 1, name: 'Tim'}, {merge: true, silent: true});
equal(col.first().get('name'), 'Tim');
});
test("Collection: add model to multiple collections", 10, function() {