Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
// 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
} else {
this.set('items', new PlaylistItems());
// Remove so parse doesn't set and overwrite instance after parse returns.
delete data.items;
return data;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment