简体   繁体   English

如何正确使用带有按钮导轨的jQuery 4

[英]how to correctly use jquery with buttons rails 4

i have 2 radio buttons, when i click on text_field rails choose first radio button, then when i click to the second radio button rails choose button, the problems begins when i click again to the text_field rails doesnt choose needed button 我有2个单选按钮,当我单击text_field rails选择第一个单选按钮时,然后当我单击到第二个单选按钮rails选择按钮时,当我再次单击text_field rails不选择所需按钮时问题就开始了

<%= f.label "I will paid" %>
        <%= f.text_field :price %>  
        <%= f.radio_button :price, true %>
        <%= f.radio_button :price, false %>
        <%= f.label "let itself will offer price" %>
        <script>
        $(document).ready(function(){
          $('#post_price_false').click(function(){
            $('#post_price').val(''); 
          });
          $('#post_price').click(function(){
            $('#post_price_false').attr('checked',false);
            $('#post_price_true').attr('checked',true);
          });

          });</script>

any ideas? 有任何想法吗?

all problem in jquery, i redid script for this: jQuery中的所有问题,我为此重做脚本:

$('#post_price').click(function(){
            $('#post_price_false').attr('checked',false);
            $('#post_price_true').attr('checked',true);

to: 至:

$('#post_price').click(function(){
                $('#post_price_false').prop('checked',false);
                $('#post_price_true').prop('checked',true);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM