Rails select_tag onchange ajax request

后端 未结 1 2000
感情败类
感情败类 2020-12-16 14:48

I am trying to make a form that adds elements to the form after certain elements have been selected. For example, After a user selects a country, I want there to be an ajax

相关标签:
1条回答
  • 2020-12-16 15:29

    It's not the tidiest code I have seen, but I see nothing wrong with it fundamentally.

    I would throw some alerts in there so you can narrow down where the problem is. You could put one in the change function to make sure that is getting hit, you could add one to the country_selection.js.erb to make sure that is getting hit. This will help a bit.

    I would also change the country_selection.js.erb to render a partial inside a div container where you want the new select to be, that way you can put that code into a partial and it will be a bit tidier. You can just pass a parameter to the partial that would be the selected country.

    0 讨论(0)
提交回复
热议问题