Created
October 19, 2012 03:17
-
-
Save Gowiem/3916041 to your computer and use it in GitHub Desktop.
Backbone Collection.fetch problem
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
(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