mirror of
https://github.com/jashkenas/backbone.git
synced 2026-01-23 05:48:10 -05:00
Merge branch 'master' of github.com:documentcloud/backbone
This commit is contained in:
@@ -537,7 +537,7 @@
|
||||
// hash indexes for `id` and `cid` lookups.
|
||||
_remove : function(model, options) {
|
||||
options || (options = {});
|
||||
model = this.getByCid(model);
|
||||
model = this.getByCid(model) || this.get(model);
|
||||
if (!model) return null;
|
||||
delete this._byId[model.id];
|
||||
delete this._byCid[model.cid];
|
||||
|
||||
@@ -70,6 +70,30 @@ $(document).ready(function() {
|
||||
equals(col.length, 4);
|
||||
equals(col.first(), d);
|
||||
});
|
||||
|
||||
test("Collection: remove in multiple collections", function() {
|
||||
var modelData = {
|
||||
id : 5,
|
||||
title : 'Othello'
|
||||
};
|
||||
var passed = false;
|
||||
var e = new Backbone.Model(modelData);
|
||||
var f = new Backbone.Model(modelData);
|
||||
f.bind('remove', function() {
|
||||
passed = true;
|
||||
});
|
||||
var colE = new Backbone.Collection([e]);
|
||||
var colF = new Backbone.Collection([f]);
|
||||
ok(e != f);
|
||||
ok(colE.length == 1);
|
||||
ok(colF.length == 1);
|
||||
colE.remove(e);
|
||||
equals(passed, false);
|
||||
ok(colE.length == 0);
|
||||
colF.remove(e);
|
||||
ok(colF.length == 0);
|
||||
equals(passed, true);
|
||||
});
|
||||
|
||||
test("Collection: fetch", function() {
|
||||
col.fetch();
|
||||
|
||||
Reference in New Issue
Block a user