0
我想使用knockout.js可见的绑定切换和取决于选择的值。当值为'5'时,我想切换元素,任何人都可以解释我要去哪里错了吗?我在foreach中也是这样做的,也许我的变量范围是错误的比较?由于切换选择和文本输入之间的可见性与knockout.js
<table border="1" cellpadding="4" cellspacing="0" id="terms_table">
<thead>
<tr class="term_row">
<th><div align="center">Percentage</div></th>
<th><div align="center">Payment Terms</div></th>
<th><div align="center">Stage</div></th>
<th><div align="center">Delete</div></th>
</tr>
</thead>
<tbody data-bind="foreach: terms" >
<tr class='spec_row'>
<td class='center'><input size='5' data-bind="value : percentage" /></td>
<td class='center'>
<select data-bind='visible: $data.term != 5, options: $parent.termOptions,
value: $data.term, optionsValue: "id", optionsText: "option"'></select>
<input data-bind='value: other, visible: $data.term == 5 ' />
</td>
<td class='center'><input size='60' data-bind="value : stage" /></td>
<td class='center' valign='middle'>
<input type='hidden' data-bind="value : id" />
<input type='hidden' data-bind="value : rank" />
<img width='12' height='12' class='move' src='/images/cursor_drag_arrow.png' />
<img width='12' height='12' class='psuedo_link' src='/images/deleteCross.gif'
data-bind='click: $parent.removeTerm' /></td>
</tr>
</tbody>
</table>
</div>
为$ data.term可观察到的财产? – 2013-03-22 11:16:45
是的,对象中的每个属性都是可观察的 – Wellso 2013-03-22 11:28:54
然后尝试我的答案。 – 2013-03-22 11:41:12