I am trying to change the following jockout model binding for my requirement: http://jsfiddle.net/zrBuL/291/ . The modification is as follows:
HTML:
<label>Male
<input type="radio" name="IsMale" value="a" data-bind="checked:IsMale"/>
</label>
<label>Female
<input type="radio" name="IsMale" value="b" data-bind="checked:IsMale"/>
</label>
<div data-bind="text: ABC()"/>
JavaScript:
var vm = {
IsMale: ko.observable(false),
ABC:ko.purelyComputed({
read: function(){
return this.IsMale();
}
},this)
};
ko.applyBindings(vm);
For the framework, I would prefer knockout.js 3.0.0.
The problem is that it does not display anything for the div above where the div text property is bound to ABC ().
Hint: if I replace the following line in the read function:
return this.IsMale();
with the following line:
return "Hi";
then it works like a charm.
Is there something I am missing when calling the IsMale property?
source
share