Getting the "Missing" itemViewcontainer "error in a composite view for a puppet

I have a composite view that throws the following error when a model is added to the collection of views: Uncaught ItemViewContainerMissingError: Missing itemViewContainer

Here is my composite:

 // VIEW B.ScrapeUpdate.View = Backbone.Marionette.CompositeView.extend({ // ITEM VIEW itemView: B.ScrapeUpdateItem.View, // ITEM VIEW CONTAINER itemViewContainer: 'tbody', // TEMPLATE template: Handlebars.compile(templates.find('#scrape-update-template').html()), // INITIALIZE initialize: function(options){ _.bindAll(this); // Bind events this.collection.bind('reset', this.renderCollection); } }); 

I found that adding the following code to initialization before binding to the collection fixes the error:

  var html = this.renderModel(); this.$el.html(html); 

I'm not sure why I need these two lines of code when I have other composite views that work fine. The following is an example of a working composite view:

 B.BusinessSearchResults.View = Backbone.Marionette.CompositeView.extend({ // ITEM VIEW itemView:B.Business.View, // ITEM VIEW CONTAINER itemViewContainer: 'tbody', // TEMPLATE template: Handlebars.compile(templates.find('#business-search-results-template').html()), // INITIALIZE initialize: function(options){ _.bindAll(this); // Bind events this.collection.bind('reset', this.renderCollection); } }); 

There seems to be no difference between the views, so I'm not sure what happened.

+4
source share
1 answer
 // INITIALIZE initialize: function(options){ _.bindAll(this); // Bind events this.collection.bind('reset', this.renderCollection); } 

these lines of code are not needed. CompositeView does this for you, out of the box. This code is probably causing the problem. Comment out the line this.collection.bind and see this.collection.bind you still get the error.

0
source

All Articles