Skip to content

Commit

Permalink
Model.remove() triggers 'remove' with removed instance as argument. A…
Browse files Browse the repository at this point in the history
…lso added test to make sure custom class events can take optional data.
  • Loading branch information
ismasan authored and benpickles committed Sep 23, 2010
1 parent 31055de commit d97252f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/model_class_methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Model.ClassMethods = {

if (index != undefined) {
this.collection.splice(index, 1);
this.trigger("remove");
this.trigger("remove", [model]);
return true;
} else {
return false;
Expand Down
12 changes: 9 additions & 3 deletions test/tests/model_callbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ test("class-level", function() {
Post.bind("remove", function() {
results.push(this);
results.push("remove");
for (var i = 0; i < arguments.length; i++) {
results.push(arguments[i].id())
};
})

Post.bind("custom", function() {
results.push(this);
results.push("custom");
for (var i = 0; i < arguments.length; i++) {
results.push(arguments[i].id())
};
}).bind("custom", function() {
results.push(this);
results.push("custom-2");
Expand All @@ -38,13 +44,13 @@ test("class-level", function() {
Post.add(post3);
Post.remove(post1);
Post.remove(666);
Post.trigger("custom");
Post.trigger("custom",[post1]);

same(results, [
Post, "add", 1, 2,
Post, "add", 3,
Post, "remove",
Post, "custom",
Post, "remove", 1,
Post, "custom", 1,
Post, "custom-2"
]);
});
Expand Down

0 comments on commit d97252f

Please sign in to comment.