Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何将页面滚动到通过 rjs 插入的部分?
page.insert_html :bottom, :comments, :partial => 'comment', :object => @comment
您必须向您的页面添加一个 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}')"