title: Backbone model: nested data structure
body: <p>I'm developing backbone app, which makes crossdomain restful request. The nested data structure in request are required, in the curl request I have that structure:</p>
  
  <pre><code>{
      "site_id": 1,
      "post": {
          "site_id": 1,
          "provider_id": 1,
          "provider_post_id":1,
          "created_ts": "12.12.12",
          "post": {
              "header": "text",
              "caption": "text",
              "image": "http://...jpg"
          }
      }
  }
  </code></pre>
  
  <p>In the model I have not nested structure and this is pretty comfortable, because I use <code>image</code> model field in the <code>view</code> (DOM element creation).</p>
  
  <p><strong>What the correct way to send nested data to server from Backbone app?</strong></p>
  
  <p>Model:</p>
  
  <pre><code>var WraperModel = Backbone.Model.extend({
      url: 'http://mydomain/core/api/v1/bookmarklet_post/?  callback=?',
      defaults: {
          site_id: 1, // shouldn't be hardcoded
          type:"type", site_id:2, provider_id: 2, provider_post_id: 2,  created_ts:2,
          header : '',
          caption: '',
          image: ''
      },
  });
  </code></pre>
  
  <p>The part of view, which use <code>image</code> model property:</p>
  
  <pre><code>drawItem: function (model) {
      var inst = new ImageView({model: model, tagName: 'li',     className:'images-item'}).render();
      this.imagesWrapper.append(inst.el);
  },
  getImages: function () {
     var images = doc.getElementsByTagName('img'),
         view = this;
     _.each(images, function (image) {
         image.offsetHeight &gt; 75 
         &amp;&amp; image.offsetWidth &gt; 75 &amp;&amp;
         view.collection.add({image: image.src});
     });
  },
  </code></pre>
  
  <p>The part of another view, which send data to server.</p>
  
  <pre><code>sendTo: function(){
      var that = this,
      data = {saving: true};
  
      $('#add-header').val() &amp;&amp; (data.header = $('#add-header').val());
      $('#add-description').val() &amp;&amp; (data.caption = $('#add-description').val());
      this.model.set(data);
      this.model.save();
  }
  </code></pre>