【发布时间】:2010-04-28 11:23:34
【问题描述】:
如何将页面滚动到通过 rjs 插入的部分?
page.insert_html :bottom, :comments, :partial => 'comment', :object => @comment
【问题讨论】:
标签: ruby-on-rails ajax rjs
如何将页面滚动到通过 rjs 插入的部分?
page.insert_html :bottom, :comments, :partial => 'comment', :object => @comment
【问题讨论】:
标签: ruby-on-rails ajax rjs
您必须在页面中添加一个 javascript 方法并从您的控制器调用它
例如:- 在您的 example.html.erb 中
function scrollToDiv(id){
// This method is used to scroll page
}
在你的控制器方法中
page.insert_html :bottom, :comments, :partial => 'comment', :object => @comment
page << "scrollToDiv('#{@comment.id}')"
【讨论】: