javascript - Knockout 'for' binding? -
original question
does 1 have or know of binding knockout allow behavior similar loop? can make foreach want nice if didn't have way.
edit 2
i trying create table rows based on selection user makes. in cases need x rows x length of array, other times x represents largest number rows needed display n number of arrays.
ex: image1 built based on 4 different arrays vary in size image2 built same array , doubled in case.

<div data-bind="if: selectedtab()"> <table> <thead> <tr> <td> <div class="a-i-post-all"></div> </td> <!-- ko foreach:$root.selectedtab().races--> <td> <input type="checkbox" /> </td> <!-- /ko --> </tr> </thead> <tbody data-bind="foreach: selectedtab().runners"> // <-- empty array created max number of runners in selectedtabs array of races <tr> <td> <div class="a-i-post"></div> </td> <!-- ko foreach:$root.selectedtab().races--> <td> <!-- ko if: runners.length > $parentcontext.$index()--> <input type="checkbox" /> <!-- /ko --> </td> <!-- /ko --> </tr> </tbody> the above works fine , creates want, don't having turn selectedtab.runners number empty array make loop n times create rows. open suggestions. note of time posted question have revised code considerably , down 1 occurrence related initial question.
my repeat binding this.
<tbody> <tr data-bind="repeat: { foreach: selectedtab().runners, index: '$runner' }"> <td> <div class="a-i-post"></div> </td> <td data-bind="repeat: selectedtab().races"> <!-- ko if: $item().runners.length > $runner --> <input type="checkbox" /> <!-- /ko --> </td> </tr> </tbody>
Comments
Post a Comment