0
<script type="text/x-handlebars" data-template-name="item-view">
  {{#with view.content.json}}
  <tr>
    <td>{{unbound artistName}}</td>
    <td>{{unbound price}}</td>
    <td>{{unbound primaryGenreName}}</td>
    <td>{{unbound version}}</td>
  </tr>
  {{/with}}
</script>

<table>
  <script type="text/x-handlebars">
    {{view Em.CollectionView itemViewClass="App.ItemView" contentBinding="App.itemsController"}}
  </script>
</table>

上述模板中的 HTML 表格标签是使用 ember-1.0.pre.js 去除的。有没有比这更合适的模式来输出有很多值的结果表?

Handlebars.js:嵌套模板去除“安全”HTML的帖子似乎与保留标签的主题相关,但 Ember 在此基础上添加了自己的抽象。

4

1 回答 1

1

查看ember 文档,我认为这就是您要查找的内容。您应该能够根据您的目标替换一堆不同的列表类型。

anUndorderedListView = Ember.CollectionView.create({
    tagName: 'tbody',
    content: ['A','B','C','D'],
    itemViewClass: Ember.View.extend({
        templateName: 'item-view'
    })
});

演示

于 2012-08-09T00:36:38.910 回答