浏览 2128 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2008-02-26
def delete_comment if request.delete? @comment = Comment.find params[:c_id] @comment.destroy blog = Blog.find params[:id] @comments = blog.comments(true) end end render code: <div id="comments"> <%= render :partial=>"comments", :object=>@comments %> </div> _comments code: <p> You have <%=pluralize(comments.count, "comment") %> : <ul> <% for c in comments %> <%= debug c %> <li> <%= c.name %> <p><%= c.context %></p> <%= link_to_remote :delete, :method=>:delete, :url=>{:action=>"delete_comment", :c_id=>c.id, :id=>@blog.id} %> </li> <% end %> </ul> </p> delete_comment.rjs code: page.replace_html("comments", :partial=>"comments", :object=>@comments) 代码有点长~ 情况是_comments局部模板在删除@comments内最后一个记录时会刷新一次,看到了ajax效果,删除倒数第2,第3个时,页面无反应... 救助... 看看是不是link_to_remote的参数使用上有问题... 谢谢! 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |