I have a backbone model like this
Report = Backbone.Model.extend({
urlRoot: '/reports'
})
What I did:
model = new Report({id: 1, name: "Test Report1"});
model.urlRoot = "/reports/" + model.get('id') + "/submit";
model.save(null, {
patch: true,
success: function(model, res){
console.log(res);
},
error: function(err){
console.log(err);
}
});
But when I save it I want it to send the request to a path like /reports/:id/submit
with patch
but it goes to a path like this /reports/1/submit/1
with POST
. What can I do here? Any tweaks? Or should I use $.ajax
instead?