如果子视图的容器视图是另一个容器视图,则会抛出错误

时间:2013-03-13 07:14:49

标签: ember.js

使用新的emberJS RC1版本,我无法将containerView添加为父容器视图的子视图。

  window.App = Ember.Application.create();

  App.Router.map(function(){
    this.resource("users");
  });

App.UsersView = Ember.ContainerView.extend({
    init : function(){
        this._super();
        this.pushObject(Ember.ContainerView.create({
    init: function(){
        this.pushObject(Ember.View.create({
            templateName : 'test1'
        }));
    }
}));
    }
});

以下是jsfiddle

1 个答案:

答案 0 :(得分:0)

您不应该使用init函数来设置对象的属性。如果你使用'didInsertElement'它可以工作:

App.UsersView = Ember.ContainerView.extend({
    didInsertElement : function(){
        this._super();
        this.pushObject(Ember.ContainerView.create({
    didInsertElement: function(){
        this.pushObject(Ember.View.create({
            templateName : 'test1'
        }));
    }
}));