0

使用新的 emberJS RC1 版本,我无法将 containerView 添加为父 containerView 的 childView。

  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

4

1 回答 1

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'
        }));
    }
}));
于 2013-03-13T11:16:31.113 回答