Created
March 2, 2014 05:46
-
-
Save krambuhl/9302506 to your computer and use it in GitHub Desktop.
Backbone Jsonp Collection. only supports simple get commands.
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.JsonpCollection = Backbone.Collection.extend({ | |
sync: function(method, model, options) { | |
var params = _.extend({ | |
type: 'GET', | |
url: this.url, | |
dataType: "jsonp", | |
processData: false | |
}, options); | |
return $.ajax(params); | |
}, | |
parse: function(response) { | |
if (this.type && response[this.type]) { | |
return response[this.type]; | |
} else { | |
return response; | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment