有没有办法点击collection_radio_button
表单会自动提交?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 %>
你应该可以做类似'<%= f.collection_radio_buttons:action,[['丢失10磅',...],:first,:last,onclick:'getElementById(“myForm”)。 submit()'%>' – MZaragoza