Answer the question
In order to leave comments, you need to log in
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: $("#comment_content").val('');
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
figured out
item_<%[email protected]%>_comments_form is the id inside which is the comment submission form with id comment_content
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 questionAsk a Question
731 491 924 answers to any question