有沒有辦法點擊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