Is there a way to redefine the url when calling model.destroy in the spine

Rigt now I call model.destroy (), a DELETE request to the server side

I want to override the url call during destruction, I cannot change urlRoot.

Is there any way?

Thanks Prats

+5
source share
2 answers

You can pass it on a call destroy.

this.model.destroy( { url: "your-custom-url/" } );

+6
source
var MyModel = Backbone.Model.extend({
    destroy: function (options) {
        var opts = _.extend({url: '/destroy/' + this.id}, options || {});
        return Backbone.Model.prototype.destroy.call(this, opts);
    }
)};

All AJAX-based interactions are ultimately handled Backbone.sync, which accepts an options object where a URL can be provided if the default URL scheme for your server is down.

+15
source

All Articles