-
-
Save MeoMix/6ee36e30ea0e9c140ee3 to your computer and use it in GitHub Desktop.
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
// 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; | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment