Rails: submit (via AJAX) when drop-down option clicked

后端 未结 5 2068
礼貌的吻别
礼貌的吻别 2021-02-04 10:14

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

5条回答
  •  一整个雨季
    2021-02-04 11:00

    In Rails 3:

    <%= form_for(membership, :remote => true) do |f| %>`
      <%= f.select :permissions, [['none', 0], ['admin', 9]], {}, :onchange => 'this.form.submit();' %>
    <% end %>
    

    Note that it's this.form.submit(); not onsubmit. And don't forget the Javascript semicolon.

提交回复
热议问题