Alex Rivera | Logout

Backbone.Model.destroy not triggering success function on success

Asked 2011-08-08T21:30:42.577
17

So, within one of my views, I've got this function:

delete_model: function() {
    var answer = confirm("Are you sure you want to delete this element?");
    if (answer) {
        this.model.destroy({
            success: function() {
                console.log("delete was a success");
            }
        });
    }
});

When I ping that, the Ajax call goes out, the backend properly deletes the model and returns a 200 header with "OK" as the body...but the success event never fires. Am I missing something? What should I have the backend serve to fire that event?

Edit
Report

1 Answer

2

That looks good to me, exactly what I have everywhere (except I have function(model) but that shouldn't matter at all) I do know that older versions of backbone didn't use the destroy(options) but instead had destroy(success, failure). Can you make sure you have the latest version.

answered 2011-08-09T18:51:22.590

Your Answer