I'm running into a little hiccup with my AJAX creation of comments for posts. Everything works great but I am doing this in the index.html.erb view so the create.js.erb is finding the first div that says "comments" and inserting the comment there.
I know how to create a post specific div by using:
<div id="comments_<%= post.id %>
But how do I reference that div with the create.js.rjs? I am assuming it is to affect the first line:
page.insert_html :bottom, :comments, :partial => @comment
where it says :comments, but not sure of the syntax here. Something like :comments_<%= post.id %> seems intuitive but since it isn't a .erb file that doesn't see to work. Thoughts?
Here is my code:
/comments/create.js.rjs
page.insert_html :bottom, :comments, :partial => @comment
page[@comment].visual_effect :highlight
page[:new_comment].reset