javascript - Knockout.js dynamic composable table -
i'm trying make "dynamic table" knockout js , i'm having bit of difficulty. want have "common row template" nested template variable columns. this:
<script type="text/x-jquery-tmpl" id="commonrow"> <td><input type="text" data-bind="value: nome" /></td> <td data-bind="template: { name: $item.labelone + 'row' }"></td> <td><button class="fancybox edit" data-bind="click: edit">modifica</button></td> <td><button class="remove" data-bind="click: remove">rimuovi</button></td> </script>
so second <td>
render template, this:
<script type="text/x-jquery-tmpl" id="scalarow"> <td><input type="text" data-bind="value: pianifuoriterra" /></td> <td><input type="text" data-bind="value: foo" /></td> </script>
this "works" has big problem: desired <td>
nested in outer <td>
template binding, causing improper alignment header (which structured same way).
i tried using {{tmpl}} syntax avoid wrapping <td>
, gets me right html, databinding , observable don't work anymore in dynamic part.
is there way render block of <td>
preserving knockout observable functionality , avoiding wrapping tag? thanks.
your best option @ using ko 1.3 beta. here sample of doing want: http://jsfiddle.net/rniemeyer/wmdfv/
<table data-bind="foreach: items"> <tr> <td data-bind="text: name"></td> <!-- ko template: type --> <!-- /ko --> </tr> </table> <script id="typea" type="text/html"> <td>typea template</td> </script> <script id="typeb" type="text/html"> <td>typeb template</td> </script>
Comments
Post a Comment