Skip to content

Instantly share code, notes, and snippets.

@Gowiem
Created October 19, 2012 03:17
Show Gist options
  • Save Gowiem/3916041 to your computer and use it in GitHub Desktop.
Save Gowiem/3916041 to your computer and use it in GitHub Desktop.
Backbone Collection.fetch problem
(function() {
define(['backbone', 'models/movie'], function(backbone, Movie, dtvCollection) {
return window.Movies = window.DTVCollection.extend({
model: Movie,
url: function() {
return this.urlRoot() + 'movies.json';
},
parse: function(response) {
console.log(response);
return response.results;
},
sync: function(method, model, options) {
var params, that;
that = this;
params = _.extend({
type: 'GET',
dataType: 'jsonp',
url: that.url(),
processData: false
}, options);
return $.ajax(params);
},
initialize: function() {
return this.fetch({
success: function() {
return console.log("SUCCESS!");
},
error: function(model, response) {
console.log(response);
}
});
}
});
});
}).call(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment