2012-03-13 52 views
2

我想使用CollectionView在表格中显示元素列表。我需要在tbody元素中添加一个类和数据属性。当我做这样的事情时:在将Ember.CollectionView呈现到表格中时设置tbody属性

App.ListView = Ember.CollectionView.extend({ 
    tagName: 'table', 
    classNameBindings: ['myClass'], 

    myClass: "my-class" 
}) 

它只设置表元素的类而不是tbody元素的类。我如何在tbody元素中设置类和其他属性?

回答

3

你可以使用tbody作为标记名巢它<table>元素中,看到http://jsfiddle.net/AKEsR/

把手:

<script type="text/x-handlebars" > 
    <table> 
     {{#collection App.ListView}} 
      <td>{{content}}</td> 
     {{/collection}} 
    </table> 
</script>​ 

的JavaScript:

App = Ember.Application.create({}); 

App.ListView = Ember.CollectionView.extend({ 
    tagName: 'tbody', 
    classNameBindings: ['myClass'], 
    myClass: "my-class", 
    content: Ember.A(['a', 'b']) 
});​