views:

22

answers:

1

How can I scroll the page to a partial, which got inserted via rjs?

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

A: 

You have to add a javascript method to your page and call it from your controler

for ex:- In your example.html.erb

function scrollToDiv(id){
     // This method is used to scroll page 
}

And in your controller method

page.insert_html :bottom, :comments, :partial => 'comment', :object => @comment
page << "scrollToDiv('#{@comment.id}')"
Salil