2012-04-19 66 views
1

如何初始化ContainerView中的子元素?如何初始化ContainerView标签中的子元素?

例如,这个模板:

{{#view Ember.CardLayout}} 

    {{view Ember.TextField}} 

{{/view}} 

这种观点:

/** 
* [Table description] 
* @type {[type]} 
*/ 
Ember.CardLayout = Ember.ContainerView.extend({ 
    title: null, 
    // ??? 
    childViews: ['testView'], 
    testView: Ember.Checkbox.create(), 
    render: function(buffer) { 
     this.forEachChildView(function(view) { 
     view.renderToBuffer(buffer); 
     }); 
    } 
}); 

非常感谢您!

回答

0

您可能需要从the documentation开始。这包含许多您可能会发现有用的示例。我建议是这样的:

App.cardLayout = Ember.ContainerView.create({ 
    title: null, 
    childViews: ['testView'], 
    testView: Ember.Checkbox.create() 
}); 

,然后模板

{{view App.cardLayout}} 

然后,您可以添加并通过操纵App.cardLayout.get('childViews')对象中删除的意见。

+0

谢谢。但我想使用标记样式编写布局代码,因为它看起来很清晰。所以我想要自定义Cardlayout控件来收集子控件和输出。 – h63542 2012-04-20 00:51:39