Skip to content

Instantly share code, notes, and snippets.

@there4
Created January 5, 2013 15:41
Show Gist options
  • Save there4/4462137 to your computer and use it in GitHub Desktop.
Save there4/4462137 to your computer and use it in GitHub Desktop.
Backbone JSONP Model Abstract.
//
// Backbone JSONP Model Abstract
// =============================================================================
//
// * Author: [Craig Davis]([email protected])
// * Since: 1/4/2013
// -----------------------------------------------------------------------------
//
define([
"jquery",
"underscore",
"Backbone"
],
function(
$, _, Backbone
) {
return Backbone.Model.extend({
sync: function(method, model, options) {
var params = _.extend({
type: "GET",
url: _.isFunction(this.url) ? this.url() : this.url,
async: false,
jsonp: "jsonCallback",
contentType: "application/json",
dataType: "jsonp",
processData: false
}, options);
return $.ajax(params);
}
});
});
/* End of file jsonp.js */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment