Skip to content

Instantly share code, notes, and snippets.

@mspanish
Created August 28, 2013 21:17
Show Gist options
  • Save mspanish/6371424 to your computer and use it in GitHub Desktop.
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
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