0

如何将页面滚动到通过 rjs 插入的部分?

page.insert_html :bottom, :comments, :partial => 'comment', :object => @comment
4

1 回答 1

1

您必须向您的页面添加一个 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}')"
于 2010-04-28T11:45:28.250 回答