开发者

Inserting AJAX page.insert_html for dynamic divs

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. Someth开发者_开发问答ing 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


page.insert_html :bottom, "comments_#{post.id}", :partial => @comment
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜