I’m using knockout and I have 2 radio buttons, when a particular one is selected I need a textbox to be enabled and disabled if the other option is selected. I can’t seem to get this working. this is what i have so far: IssercentageBased is a boolean on my viewmodel and i’ve set it up to be an observable. any ideas?
<input type="radio" name="IsPercentageBased" value="true" data-bind="checked: IsPercentageBased"/>
<span>Percentage</span>
<input type="radio" name="IsPercentageBased" value="false" data-bind="checked: IsPercentageBased"/>
<span>Value</span>
@Html.TextBox("Value", "", new
{
type = "text",
data_bind = "value: Value, valueUpdate: 'afterkeydown', disable: IsPercentageBased"
})
Update data-bind attribute of text box to this:
Checkedbinding sets to observable value ofValueattribute and that isstringto abool.Here is working fiddle: http://jsfiddle.net/vyshniakov/wDRuG/