2

关于我阅读的不同帖子,我预计以下代码应该可以工作:

<tbody>
    {{#each NewApp.router.gridController.tableContent}}
        {{#view NewApp.TableRow rowBinding="this"}}
            <td style="width: 100px">{{row.item_no}}</td>
            <td align="right" style="width: 100px">{{row.price}}</td>
            <td>{{row.name}}</td>
        {{/view}}
    {{/each}}
</tbody>

但我只得到空表行。如果我使用 tr 一切都按预期工作。

TableRow 定义为:

NewApp.TableRow = Ember.View.extend({
  tagName: "tr",

  row: null,

  willInsertElement: function() {
    console.dir(this.get("row"));
  }

});

顺便说一句:console.dir 显示正确的数据。

问候罗杰

4

1 回答 1

2

您可以查看http://docs.emberjs.com/#doc=Ember.CollectionView&src=false,它可以简化您的代码。

对于您的示例,在模板中使用 {{view.row.XXX}} ,它应该可以完成这项工作

于 2012-07-17T20:41:14.543 回答