Alex Rivera | Logout

Destroying a Backbone Model in a Collection in one step?

Asked 2011-06-08T14:38:44.883
20

Are these two steps mandatory to delete a Model?

var model = collection.get(id);
model.destroy();
collection.remove(model);

Isn't there a way to destroy a model when it is removed from its collection?

Edit
Report

1 Answer

1

Calling collection.reset() without passing any models as arguments will empty the entire collection.

http://backbonejs.org/#Collection-reset

answered 2012-11-15T08:21:49.627

Your Answer