In this case, i think that a nice choice is to make the writeable computed evident a “sub-observable” of your IsActive discernible. Your view model would look like:

var ViewModel = function() {
 this.IsActive = ko.observable(true);

this.IsActive.ForEditing = ko.computed({
 read: function() {
 return this.IsActive().toString(); 
 },
 write: function(newValue) {
 this.IsActive(newValue === "true");
 },
 owner: this 
 }); 
};

Bind in your html file like this:
<label>Male
 <input type="radio" name="IsActive" value="true" data-bind="checked:IsActive.ForEditing"/>
</label> 
<label>Female
 <input type="radio" name="IsActive" value="false" data-bind="checked:IsActive.ForEditing"/>
</label>

 

Leave a Reply

Your email address will not be published. Required fields are marked *