Created
January 5, 2013 15:41
-
-
Save there4/4462137 to your computer and use it in GitHub Desktop.
Backbone JSONP Model Abstract.
This file contains hidden or 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
// | |
// 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