0

我有单选按钮,如果我选择第一个变体,我想我<%= f.text_field :price %>是可用的,如果我选择第二个变体<%= f.text_field :price %>不可用

<%= f.radio_button :price, true %><%= f.label :price %>
    <%= f.text_field :price %>
    <%= f.radio_button :price, false %><%= f.label :price %>
    <%= radio_button_tag(:price, "price") %>

你怎么能这样做?

4

1 回答 1

0

一位好人建议使用此脚本:

<%= f.radio_button :price, false %><%= f.label :price %>
    <%= f.text_field :price %>
    <%= f.radio_button :price, true %><%= f.label :price %>
    <script>$(document).ready(function(){
      $('#post_price_true').change(function(){
        $('#post_price').attr('disabled','disabled');
      });
      $('#post_price_false').change(function(){
        $('#post_price').removeAttr('disabled');
      });
      });</script>

奥丁诺尔诉波尔祖兹瑞特莱

于 2013-11-11T15:55:58.713 回答