2015-06-30 1 views
1

Вот мой LayoutView:Marionette.js Не удалось выполнить 'AppendChild' на 'Node': Параметр 1 не типа 'Узел'

define(["marionette", "lodash", "text!fonts/template.html", 
"fonts/controls/view", "fonts/products/view"], 
function(Marionette, _, templateHTML, ControlsView, ProductsView) { 
    'use strict'; 

    var FontsView = Marionette.LayoutView.extend({ 

     regions: { 
      controls: '#controls', 
      products: '#products-list' 
     }, 

     template: _.template(templateHTML), 

     onRender: function() { 
      this.getRegion('controls').show(new ControlsView()); 
      this.getRegion('products').show(new ProductsView()); 
     } 
    }); 

    return FontsView; 

}); 

Вот мой ProductsView:

define(["marionette", "lodash", "text!fonts/products/template.html", 
'fonts/products/item-view', 'fonts/products/collection'], 
function(Marionette, _, templateHTML, ProductItemView, ProductsCollection) { 
    'use strict'; 

    var ProductsView = Marionette.CompositeView.extend({ 
     el: '.items', 

     template: _.template(templateHTML), 

     childView: ProductItemView, 

     initialize: function() { 
      this.collection = new ProductsCollection(); 
     } 
    }); 

    return ProductsView; 
}); 

Ошибка (из консоли) происходит на this.getRegion('products').show(new ProductsView());

+0

Я подозреваю, что в HTML-формате Layoutview нет элемента с идентификатором 'products-list' – ivarni

ответ

4

Удалите el: '.items', из ProductsView, и он будет работать. Marionette уже управляет регионом и запутывается, когда el задается в дочернем представлении.