2012-11-06 123 views
1

我正在使用淘汰赛,并且我有2个单选按钮,当选中某个特定按钮时,如果选择了其他选项,我需要启用和禁用文本框。我似乎无法得到这个工作。这是我迄今为止:IssercentageBased是我的viewmodel布尔值,我已经设置它是一个可观察。有任何想法吗?文本框的单选按钮中的单选按钮

<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" 
       }) 

回答

2

更新数据绑定属性这样:

data_bind = "value: Value, valueUpdate: 'afterkeydown', disable: IsPercentageBased() == 'true'" 

Checked结合集来Value属性的可观察到的值,这是stringbool

这里是工作小提琴:http://jsfiddle.net/vyshniakov/wDRuG/