Pianista2016-05-17 20:04:43
Ruby on Rails
Pianista, 2016-05-17 20:04:43

Ajax comment submission form in Rails. How to clear it after sending, if there are several forms?

There are several items on the page, each has comments and a comment submission form.
How to make the form empty again after submitting a comment via Ajax.
This option only works for the first form:
Each form needs its own unique id, but how do I do that?
You can set a unique id for the form div, like id="comments_form_<%= item.id %>, but the above method only works for the form, not the div.
Are there other options?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Pianista, 2016-05-20

figured out
item_<%[email protected]%>_comments_form is the id inside which is the comment submission form with id comment_content

ThunderCat, 2016-05-17

And do you have all input fields have the same id? Do you notice anything strange?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question