2012-11-06 206 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/