Created
February 1, 2013 16:35
-
-
Save sap1ens/4692429 to your computer and use it in GitHub Desktop.
Adding Backbone.js custom REST method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
options = _.extend(options, opts);