Rails Trying to submit a form onchange of dropdown

后端 未结 11 1284
遥遥无期
遥遥无期 2020-12-13 20:28

I have my Ajax working, builtin Rails javascript, with the submit button. However, I would like it to submit when I change the value of the dropdown box and eliminate the b

11条回答
  •  佛祖请我去吃肉
    2020-12-13 21:31

    This is what I was able to do to get it to work. I named the form switch_car by using :name => "switch_car" and used the following javascript.

    :onchange => ("javascript: document.switch_car.submit();")
    

    I am still looking for a better answer so I will updated if I find something. This doesn't use submit .js for some reason. It processes it as HTML unlike the submit button which uses AJAX to update only the changing page elements. But this is the best I have been able to find so far.

提交回复
热议问题