JSFiddle - React, Tailwind, and code Playground
by fastfasterfastest
HTML
<script src="http://bestware.us/knockout/3.5.0-pre-20170505/knockout-latest.debug.js"></script>
<div>Checkbox value: <span data-bind="text:value"></span></div>
<div>
Checkbox checked:<span data-bind="text:checked"></span>
<button type="button" data-bind="text: 'Set ' + (checked()?false:true), click: function(){ this.checked(this.checked()?false:true); }"></button>
<button type="button" data-bind="click: function(){ this.checked(this.value()); }">Set 14</button>
</div>
<div>
=> <input type="checkbox" data-bind="value: value, checked: checked" />
</div>
JavaScript
function ViewModel() {
this.value = ko.observable(14);
this.checked = ko.observable(false);
}
//ko.options.deferUpdates = true;
ko.onError = function (error) {
alert("knockout error\n" + error);
}
ko.applyBindings(new ViewModel())