My back-end has two separate pages, one for handling the model save request and the other for model fetch.
What is the best approach for calling save() and fetch()
Gingerhendrix's answer covers the bases, but I thought it was worth elaborating on the method for passing in an options value for save/delete/fetch.
Instead of littering your code with urls every place you call one of those methods, you can also override the method on your model than then delegate back to the original Backbone.Model method like this:
var MyModel = Backbone.Model.extend({
save: function(attributes, options) {
options = _.defaults((options || {}), {url: "http://your.save.url.com/"});
return Backbone.Model.prototype.save.call(this, attributes, options);
},
// same thing for fetch and delete to give them different urls...
}
Then, you can call the method in your code without having to worry about remembering to set the url in the options.