Ruby on Rails: Submit a form as a JS based on a change in select box

后端 未结 3 730
悲&欢浪女
悲&欢浪女 2020-12-21 16:23

I have the following HTML generated by form_tag and select_tag in Rails:

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-21 16:42

    I solved the problem doing it the following way:

    <%= f.select :foldernames, options_for_select(@folders, @folders.first), {}, {:onchange=>"myfunc()"}%>
    

    and i added

    
    

    and the form is being submitted as JS instead of HTML. It would be very helpful if someone can explain me why this is being submitted as JS instead of HTML The same code when i write :onchange=> this.form.submit, is being submitted as HTML

提交回复
热议问题