2015-06-30 113 views
1

这里是我的LayoutView:Marionette.js无法执行 '的appendChild' 的 '节点':参数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

我怀疑Layoutview的HTML中没有元素,其id为'products-list' – ivarni

回答

4

从ProductsView中删除el: '.items',,它将工作。 Marionette已经在管理该地区,并在儿童视图中指定el时感到困惑。

相关问题