I am trying to create a template in my application recursively. I have a multidimensional array that I'm trying to flatten into table rows. I can make the first level work fine, but I cannot get the next levels for rendering.
I know that Durandal requires a view to have one root element. I use a virtual container to create my template.
Here is my parental look
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>#</th>
<th></th>
<th>Condition</th>
<th>Index Field</th>
<th>Operator</th>
<th>Value</th>
</tr>
</thead>
<tbody data-bind="foreach:queryItems">
</tbody>
</table>
Here is my template
<tr>
<td data-bind="text: $data.subItems().length"></td>
<td style="width: 10%;"><button type="button" class="btn btn-sm btn-info" data-bind="click: $root.onAddSubconditionClick">Add sub-condition</button></td>
<td data-bind="text: $data.condition"></td>
<td data-bind="text: $data.indexField"></td>
<td data-bind="text: $data.operator"></td>
<td data-bind="text: $data.value"></td>
</tr>
Everything is fine until I add an element, and then the composition still works, but I do not get the last element.
Does anyone have a workaround for this?
Thank.
source
share