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?
Model.bind("remove", function() {
this.destroy();
});
...
var model = new Model();
...
collection.remove(model);
Removing a model from a collection triggers the "remove"
event.
So if you want to, you can get models to bind to them and destroy themselves.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With