What is the easiest and most graceful way to auto-submit an AJAX form when a drop-down box\'s option is selected? I\'m creating an administration page where the admin can modify
I am using Rails 5 & I was also facing the similar situation but in my case the answer given by @scott was not submitting the form using AJAX
as expected though I added the remote: true
option to the form (I don't have submit
button in the form).
If somebody is also facing the similar problem try to change the JS code like this-
<% form_for membership remote: true, id: '#member_form' do |f| %>
<%= f.select :permissions, [['none', 0], ['admin', 9]], onchange: '$("#member_form").trigger("submit");' %>
<% end %>
Hope this helps..