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

后端 未结 5 2065
礼貌的吻别
礼貌的吻别 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:05

    Three steps!

    1. Make your form_for a remote_form_for; add an id!
    2. Add an observe_field after your select
    3. Configure your observe_field to submit your form

    The last bit looks something like:

    <%= observe_field "id_of_select", :function => "$('form_id').submit();" %>
    

提交回复
热议问题