From 2ca43eaa5f9a8b9c7fb0fa51053c3c49c8be254d Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Tue, 5 Oct 2010 15:51:23 -0400 Subject: [PATCH] fleshing out destroy --- backbone.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backbone.js b/backbone.js index 8db4e171..990eca32 100644 --- a/backbone.js +++ b/backbone.js @@ -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; }