Created
August 28, 2013 21:17
-
-
Save mspanish/6371424 to your computer and use it in GitHub Desktop.
Fetch json and put into collection, Backbone
From https://snipt.net/search/?q=backbone
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
Fetch a collection require an array: | |
{ | |
'wrapper' : [ | |
{ | |
id:0, | |
name: 'Little Model 0' | |
}, | |
{ | |
id:1, | |
name: 'Little Model 1' | |
}, | |
... | |
] | |
} | |
MyCollection = Backbone.Collection.extend({ | |
url: 'http://myfavouriteapi.com/api' | |
parse: function(response) { | |
return response.wrapper | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment