Rigt now i am calling model.destroy(), a DELETE request to the server side
I want to override the url call while doing destroy, I wont be able to change the urlRoot.
Is there any way ?
Thanks, Prats
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 by Backbone.sync
which takes an options object where the URL can be provided if backbone's default URL scheme doesn't work for your server.
You can pass it when calling destroy
.
this.model.destroy( { url: "your-custom-url/" } );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With