我正在尝试查看是否可以找到与这部分 jQuery 相当的淘汰赛:
http://jsfiddle.net/chriscoyier/BPhZe/76/
这是我到目前为止所要做的,但是所有项目都绑定到同一个可观察对象,所以它显然不起作用。
html:
<form>
<div>
<input type="checkbox" name="option-1" id="option-1" data-bind="checked: buttonEnabled"> <label for="option-1">Option 1</label>
</div>
<div>
<input type="checkbox" name="option-2" id="option-2" data-bind="checked: buttonEnabled"> <label for="option-2">Option 2</label>
</div>
<div>
<input type="checkbox" name="option-3" id="option-3" data-bind="checked: buttonEnabled"> <label for="option-3">Option 3</label>
</div>
<div>
<input type="checkbox" name="option-4" id="option-4" data-bind="checked: buttonEnabled"> <label for="option-4">Option 4</label>
</div>
<div>
<input type="checkbox" name="option-5" id="option-5" data-bind="checked: buttonEnabled"> <label for="option-5">Option 5</label>
</div>
<div>
<input type="button" value="Do thing" data-bind="enable: buttonEnabled">
</div>
</form>
javascript:
var viewModel = {
buttonEnabled: ko.observable(true)
};
ko.applyBindings(viewModel);