title: Backbone.Marionette - Collection within CompositeView, which itself is nested in a CollectionView
body: <p>**UPDATE: The problem probably involves the tour-template as I've discovered that it thinks the 'name' attribute is undefined. This leads me to think that it's not an array being passed on to the ToursView, but for some reason a string. **</p>
  
  <p>After studying similar questions on StackOverflow:</p>
  
  <p><a href="https://stackoverflow.com/questions/13575101/how-to-handle-nested-compositeview-using-backbone-marionette">How to handle nested CompositeView using Backbone.Marionette?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/11838390/how-do-you-properly-display-a-backbone-marionette-collection-view-based-on-a-mod">How do you properly display a Backbone marionette collection view based on a model javascript array property?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/12163118/nested-collections-with-backbone-marionette">Nested collections with Backbone.Marionette</a></p>
  
  <p>... and Derick Bailey's excellent blog's on this subject:</p>
  
  <p><a href="http://lostechies.com/derickbailey/2012/04/05/composite-views-tree-structures-tables-and-more/" rel="nofollow noreferrer">http://lostechies.com/derickbailey/2012/04/05/composite-views-tree-structures-tables-and-more/</a></p>
  
  <p>... including the JSFiddle's:</p>
  
  <p><a href="http://jsfiddle.net/derickbailey/AdWjU/" rel="nofollow noreferrer">http://jsfiddle.net/derickbailey/AdWjU/</a></p>
  
  <p>I'm <strong>still</strong> having trouble with a displaying the last node of a nested CollectionView of CompositeViews. It is the final CollectionView within each CompositeView that is causing the problem.</p>
  
  <pre><code>CollectionView {
      CompositeView{
          CollectionView {} //**&lt;-- This is the troublemaker!**
          }
      }
  </code></pre>
  
  <p><strong>NOTE: I have already made a point of creating a valid Backbone.Collection given that the collection passed on to the final, child CollectionView is just a simple array.</strong> </p>
  
  <p>Data returned from the api to ToursList:</p>
  
  <pre><code>[
  {   "id": "1", 
      "name": "Venice", 
      "theTours": "[
          {'name': u'test venice'}, 
          {'name': u'test venice 2'}
      ]"
  }, 
  
  {   "id": "2", 
      "name": "Rome",
      "theTours": "[
          {'name': u'Test rome'}
      ]"
  }, 
  {   "id": "3", 
      "name": "Dublin", 
      "theTours": "[
          {'name': u'test dublin'}, 
          {'name': u'test dublin 2'}
      ]"
  }
  ]
  </code></pre>
  
  <p>I'm trying to nest these in a dropdown where the nav header is the 'name' (i.e. Dublin), and the subsequent li 's are the individual tour names (i.e. 'test dublin', 'test dublin2', etc.)</p>
  
  <p><strong>Tour Models and Collections</strong></p>
  
  <pre><code>Tour = TastypieModel.extend({});
  
  ToursGroup = TastypieCollection.extend({
    model: Tour
  });
  
  ToursByLoc = TastypieModel.extend({});
  
  ToursList = TastypieCollection.extend({
    model: ToursByLoc,
    url:'/api/v1/location/',
  });
  </code></pre>
  
  <p><strong>Tour Views</strong></p>
  
  <pre><code>TourView = Backbone.Marionette.ItemView.extend({
    model: Tour,
    template: '#tour-template',
    tagName: 'li',    
  });
  
  
  ToursByLocView = Backbone.Marionette.CompositeView.extend({
    collection: ToursByLoc,
  
    template: '#toursByLoc-template',
    itemView: TourView,
    itemViewContainer: '#ind',
  
    initialize: function(){
      //As per Derick Bailey's comments regarding the need to pass on a
      //valid Backbone.Collection to the child CollectionView
      //REFERENCE: https://stackoverflow.com/questions/12163118/nested-collections-with-backbone-marionette
  
      var theTours = this.model.get('theTours');
      this.collection = new ToursGroup(theTours);
      console.log(this.model.get('name'));
      console.log(theTours);
      //To test the output --&gt; I get:
  
      //Venice
      //[{'subtitle': u'ex. These prices include... but not...', 'description': u'Please enter the tour description here', 'start_time': datetime.time(2, 34, 24), 'adult_price': Decimal('123'), 'important': u'ex. Please contact us to negotiate a price if you want to book the Fiat for 1 person only.', 'teenager_student_price': Decimal('123'), 'child_price': Decimal('123'), 'under_6_price': Decimal('123'), 'location_id': 1, 'id': 1, 'name': u'test venice'}, {'subtitle': u'ex. These prices include... but not...', 'description': u'Please enter the tour description here', 'start_time': datetime.time(20, 4, 57), 'adult_price': Decimal('222'), 'important': u'ex. Please contact us to negotiate a price if you want to book the Fiat for 1 person only.', 'teenager_student_price': Decimal('222'), 'child_price': Decimal('222'), 'under_6_price': Decimal('222'), 'location_id': 1, 'id': 2, 'name': u'test 2'}] main.js:64
  
      //Rome
      //[{'subtitle': u'ex. These prices include... but not...', 'description': u'Please enter the tour description here', 'start_time': datetime.time(1, 28, 25), 'adult_price': Decimal('123'), 'important': u'ex. Please contact us to negotiate a price if you want to book the Fiat for 1 person only.', 'teenager_student_price': Decimal('333'), 'child_price': Decimal('333'), 'under_6_price': Decimal('333'), 'location_id': 2, 'id': 3, 'name': u'test rom1'}] main.js:64
  
      //Dublin
      //[] 
  
      this.collection = new ToursGroup(theTours);
    }
  });
  
  ToursListView = Backbone.Marionette.CollectionView.extend({
    itemView: ToursByLocView,
  });
  </code></pre>
  
  <p><strong>Templates</strong></p>
  
  <pre><code>  &lt;script id="tour-template" type="text/template"&gt;
      &lt;%= name %&gt; //&lt;-- THIS IS GIVING ME ISSUES
    &lt;/script&gt;
  
    &lt;script id="toursByLoc-template" type="text/template"&gt;
      &lt;li class="nav-header"&gt;&lt;%= name %&gt;&lt;/li&gt;
      &lt;div id="ind" class="indTours"&gt;&lt;/div&gt;
      &lt;li class="divider"&gt;&lt;/li&gt;
    &lt;/script&gt;
  
    &lt;script id="tours-template" type="text/template"&gt;
      &lt;%= name %&gt;
    &lt;/script&gt;
  </code></pre>