テーブルを表す必要があるビューを持ち、 と を持ちcolumns
ますrows
:
App.ListView = Ember.View.extend({
templateName: 'list',
columns: ['t1', 't2', 't3'],
rows: [
{ t1: 'one', t2: 'two', t3: 'three' },
{ t1: 'two', t2: 'one', t3: 'seven' }
]
});
- それぞれテンプレート:
<table>
<thead>
<tr>
{{#each columns}}
<th>{{this}}</th>
{{/each}}
</tr>
</thead>
<tbody>
{{#each rows}}
<tr>
{{#each ../columns}}
<td>does nothing: {{this}}</td>
{{/each}}
</tr>
{{/each}}
<tbody>
<table>
... jsfiddleでも見つけることができます: jsfiddle.net/nWnf2
行にネストされている場合、明らかに列を反復処理できません。{{#each ../columns}}
まったくトリガーされません。何故ですか?より良いアプローチは何ですか?