secret
Created

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// Convert data which is sent from the server back to a proper Backbone.Model.
// Need to recreate submodels as Backbone.Models else they will just be regular Objects.
parse: function (data) {
 
if (data.items.length > 0) {
// Reset will load the server's response into items as a Backbone.Collection
this.get('items').reset(data.items);
 
} else {
this.set('items', new PlaylistItems());
}
// Remove so parse doesn't set and overwrite instance after parse returns.
delete data.items;
return data;
},

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.