There is no True True for handling nested collections in Backbone. Quoting from Frequently Asked Questions about the backbone network :
The backbone does not include direct support for nested models and collections, or โhas manyโ associations, because there are many good templates for modeling structured data on the client side, and Backbone should serve as the basis for implementing any of them.
Frequently asked questions also offers one template and provides a link to the Extensions, Plugins, Resources page, which links to many libraries that you can use to process nested models and model relationships.
However, I sometimes approached such a problem:
var Author = Backbone.Model.extend({ initialize: function(attrs, options) { //convert the child array into a collection, even if parse was not called var books = attrs ? attrs.books : []; if(!(books instanceof Books)) { this.set('books', new Books(books), {silent:true}); } }, //the books property does not need to be declared in the defaults //because the initialize method will create it if not passed defaults: { firstName: '', lastName: '' }, //override parse so server-sent JSON is automatically //parsed from books array to Books collection parse: function(attrs) { attrs.books = new Books(attrs.books); return attrs; }, //override toJSON so the Books collection is automatically //converted to an array toJSON: function() { var json = Backbone.Model.prototype.toJSON.call(this); if(json.books instanceof Books) { json.books = json.books.toJSON(); } return json; } });
Comments, I hope, explain how this works, but the fact is that you can use the model as usual: initialize children using a collection, array or nothing, get from the server, send them to the server, everything should work transparently. There is quite a bit of template code for writing, but it is relatively simple to abstract into a base class if you find yourself repeating the same code.
Edit: A small correction, you do not need books defined in the defaults object, because the constructor creates it if it is missing.
/ sample code not tested