Skip to content

Instantly share code, notes, and snippets.

@sap1ens
Created February 1, 2013 16:35
Show Gist options
  • Save sap1ens/4692429 to your computer and use it in GitHub Desktop.
Save sap1ens/4692429 to your computer and use it in GitHub Desktop.
Adding Backbone.js custom REST method
var MyModel = Backbone.Model.extend({
someMethod: function(opts) {
var url = this.url() + '/someMethod',
// note that these are just $.ajax() options
options = {
url: url,
type: 'POST'
};
// add any additional options, e.g. a "success" callback or data
_.extend(options, opts);
return (this.sync || Backbone.sync).call(this, null, this, options);
}
});
@mattduggan
Copy link

options = _.extend(options, opts);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment