fleshing out destroy

This commit is contained in:
Jeremy Ashkenas
2010-10-05 15:51:23 -04:00
parent 1074f247cd
commit 2ca43eaa5f

View File

@@ -254,7 +254,13 @@
// Destroy this model on the server.
destroy : function(options) {
Backbone.request('DELETE', this, options.success, options.error);
options || (options = {});
var model = this;
var success = function(resp) {
if (model.collection) model.collection.remove(model);
if (options.success) options.success(model, resp);
};
Backbone.request('DELETE', this, success, options.error);
return this;
}