Knockout js: Bind checkbox enable when boolean is false
checkbox, knockout.js
Solution
I would recommend you to read the following article: 10 Things to Know About KnockoutJS Quote from the article:
Most bindings will call ko.utils.unwrapObservable on the value passed to it, which will safely return the value for both observables and non-observables. However, in a binding if you use an observable in an expression, then you need to reference it as a function. Likewise, in code you typically need to reference your observables as functions, unless you actually want to pass the observable itself (not the value).
So you should add `()` to observable when you use them in an expression:
<input type="checkbox" data-bind="checked: IsEnabled, enable: !IsDefault()" />
Problem
Each of my elements has IsAnabled and IsDeafult. If IsDefault = true, then the checkbox should be disabled. When I do like this it works, except I want the oppsite effect for "enable": ``` <input type="checkbox" data-bind="checked: IsEnabled, enable: IsDefault" /> ``` I have tried: ``` <input type="checkbox" data-bind="checked: IsEnabled, enable: !IsDefault" /> <input type="checkbox" data-bind="checked: IsEnabled, enable: IsDefault == 'false'" /> <input type="checkbox" data-bind="checked: IsEnabled, enable: IsDefault != 'true'" /> <input type="checkbox" data-bind="checked: IsEnabled, enable: IsDefault != true" /> <input type="checkbox" data-bind="checked: IsEnabled, enable: IsDefault == '0'" /> ``` but still no luck...