gpt4 book ai didi

javascript - collection_radio_buttons 自动提交?

转载 作者:行者123 更新时间:2023-11-28 15:12:27 25 4
gpt4 key购买 nike

有没有办法在点击collection_radio_button时表单会自动提交?

这样他们就不必单击提交按钮,它会自动发生。

<%= simple_form_for(@challenge) do |f| %>
<%= f.text_field :action %>
Or choose a featured challenge:
<%= f.collection_radio_buttons :action, [['Lose 10 Pounds','Lose 10 Pounds'], ['Exercise','Exercise'], ['Quit Smoking','Quit Smoking'], ['Run a 5K','Run a 5K'], ['Meditate','Meditate'], ['Visit Rome','Visit Rome'], ['Read a Chapter','Read a Chapter'], ['Walk 10,000 Steps','Walk 10,000 Steps'], ['Study a Foreign Language','Study a Foriegn Language'], ['No T.V.','No T.V.'], ['Backpack through Europe','Backpack through Europe'], ['Journal','Journal'], ['Go Vegetarian','Go Vegetarian']], :first, :last %>
<%= f.submit %>
<% end %>

最佳答案

你可以试试这个...

$('input[type=radio]').on('change', function() {
$(this).closest("form").submit();
});

此处使用了属性选择器,您可能希望将其更改为类或更具体的内容以满足您的需求。

关于javascript - collection_radio_buttons 自动提交?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35819287/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com