我正试图用这个漂亮的自举开关替换表中的复选框.
我也使用此链接建议的knockout和绑定处理程序.
但是我无法使绑定处理程序工作,或者在使用每个敲除的表构建的表中可以单击该开关.
我在jsfiddle中复制了这个问题.
我还在学习javascript和淘汰赛,只是无法弄清楚绑定处理程序或交换机出了什么问题.
有任何想法吗?
Html:
<div>
<input type="checkbox" data-bind="checked: on" />
</div>
<div>
<span data-bind="text: on() ? 'on' : 'off'"></span>
</div>
<div class="switch switch-large" data-bind="bootstrapSwitchOn: on">
<input type="checkbox" />
</div>
<p>Why doesn't this work in a table?</p>
<table class="table table-striped table-condensed table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Old</th>
<th>Old toggle With CheckBox</th>
<th>Old toggle With Switch</th>
</tr>
</thead>
<tbody data-bind="foreach: items">
<tr>
<td data-bind="text: Name"></td>
<td data-bind="text: Old"></td>
<td>
<input type="checkbox" data-bind="checked: Old" /> …Run Code Online (Sandbox Code Playgroud)