title: Backbone.js saving model with attribute that is array of other models
body: <p>im writing first open source Backbone.js app.
  The repository is here <a href="http://backbone-invoices.brillante.pl/" rel="nofollow">https://github.com/defrag/Backbone-Invoices</a></p>
  
  <p>Im having problem with saving array of LineItems for Invoice. Well, only saving after editing, because it saves the line items from currently edited invoice, to all invoices in localstorage. Dunno why this is happening, they have always same Cids.
  The default line item while creating invoice have always cid0. Any help?</p>
  
  <pre><code>class window.Invoice extends Backbone.Model
  
    initialize: -&gt;
  
    defaults:
      date: new Date
      number: '000001'
      seller_info: null
      buyer_info: null  
      line_items: [new LineItem]
  </code></pre>
  
  <hr>
  
  <p>The last thing i do not understand is why backbone isnt saving the nested attributes. As you will see in repo i do:</p>
  
  <pre><code>handleSubmit: (e) -&gt;        
  data = { 
    date : @$("input[name='date']").val(), 
    number : @$("input[name='number']").val(), 
    buyer_info : @$("textarea[name='buyer_info']").val(), 
    seller_info : @$("textarea[name='seller_info']").val(),
    line_items: @model.line_items.toJSON()
  }    
  
  if @model.isNew()
    invoices.create(data)
  else
    @model.save(data)
  
  e.preventDefault()
  e.stopPropagation()    
  $(@el).fadeOut 'fast', -&gt;
    window.location.hash = "#"
  </code></pre>
  
  <p>The things is after editing form and changing values of line items, they do not change in collection. Adding new to invoice line items collection works. Any help? :) I have some hard time with understanding how everyhing works :)</p>
  
  <p>You can check it here: <a href="http://backbone-invoices.brillante.pl/" rel="nofollow">http://backbone-invoices.brillante.pl/</a></p>