Currently facing a small issue with my AJAX implementation for creating comments on posts. The functionality is working well, but the problem arises when executing it in the index.html.erb view. The create.js.erb file locates the initial div labeled "comments" and inserts the comment there.
I am aware of how to generate a post-specific div using:
<div id="comments_<%= post.id %>
However, I'm unsure about referencing that div within the create.js.rjs file. I presume it involves modifying the line:
page.insert_html :bottom, :comments, :partial => @comment
The syntax might look something like :comments_<%= post.id %>, which seems logical, but since it's not an .erb file, that approach doesn't seem to work. Any suggestions?
Below is an excerpt from my code:
/comments/create.js.rjs
page.insert_html :bottom, :comments, :partial => @comment
page[@comment].visual_effect :highlight
page[:new_comment].reset