dimanche 22 février 2015

Saving a Backbone model where i've created a collection inside

I have a model called 'Playlist' I got back from the server which has an array of objects called 'videos'. When i fetch the 'Playlist' data from the server I need to turn 'videos' into a Collection. I update the models in the 'videos' collection sometimes. Now when I go to save 'Playlist' model, will there be a problem because I've set the 'videos' attribute to a Collection? Will I need to turn it back into a raw array of items before saving it?


If anyone can give me any tips on the best pattern for this situation that would be good. Perhaps I should create a separate collection and leave the Playlist's 'video' attribute alone and when I go to save the Playlist model I can override the Playlist's video attribute with a raw copy of the Collection.


Aucun commentaire:

Enregistrer un commentaire