Reputation: 53
I have a 2D array in a JSON object (called table ;)
data = {
tableID : "testTable",
table : [
[{type:'a', value:'x'},{type:'a', value:'y'},{type:'a', value:'z'}],
[{type:'a', value:'x'},{type:'a', value:'y'},{type:'a', value:'z'}],
[{type:'a', value:'x'},{type:'a', value:'y'},{type:'a', value:'z'}]
]
};
And have been successfully rendering it out with handlebars using the template:
<table id = "{{tableID}}-table">
{{#each table}}
<tr id = "{{../tableID}}-row-{{@index}}">
{{#each this}}
<td id = "{{../../tableID}}-row-{{../index}}-col-{{@index}}">
{{this.type}}-{{this.value}}
</td>
{{/each}}
</tr>
{{/each}}
</table>
However, in the td tag id I can't seem to access the parent index {{../index}} - the index of the row. Nothing is returned:
<td id = "testTable-row--col-x">
However, I can access the index of the current context {{@index}}.
Any ideas??
Many many thanks in advance!!
Rich
p.s. Using 1.0.0-rc.3
Upvotes: 5
Views: 2072
Reputation: 808
This is an open issue/feature on handlebar. You can check the progress for the same here
However you can check the workaround here
Upvotes: 2