When I call Model.destroy, it sends the proper requests to the server. However, I handle errors not so RESTful
, I return a JSON with some appropriate information instead of throwing a http exception.
Now I want to be able to prevent the deletion of the model in the callbacks. For ex;
window.UserView = Backbone.View.extend({
//Other stuff here.
clearSuccess: function (model, response) {
if (!response.Exception) {
$(this.el).fadeOut('fast', function() {
$(this).remove();
});
}
else {
//Can I cancel the destroy here?
}
},
clearFailed: function (model, response) {
alert("failed");
}
});
These are the 2 callbacks that I sent to the model's success
and error
parameter on the destroy
method. So where my comment is, I'd like to tell Backbone.js "nevermind, server said I cant delete, so keep the model". How do I do this?