Hi, Im updating a scrollable div with many links_to_remote. If a user has scrolled half way down the div and then clicks the link_to_remote outside the div it then updates the scrollable div but stays half way down. I want it to automatically go back to the top of the div. The code is below for the link to remote, is this possible to do? <%= link_to_remote "Update Div", :url => { :action => "load_questions", :id => category}, :before => "Element.show(''main_spinner'')", :success => "Element.hide(''main_spinner'')" %> Any help appreciated. JB -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
John Butler wrote:> Im updating a scrollable div with many links_to_remote. If a user has > scrolled half way down the div and then clicks the link_to_remote > outside the div it then updates the scrollable div but stays half way > down. I want it to automatically go back to the top of the div.Perhaps you could do a javascript "focus" on an element at the top of the div in question? I haven''t tried it, so no guarantees, but it may work. Similar to having <a name="top"></a> for use with links that hop around the page (common usage for FAQ pages), you could make an empty <a> tag with id="top" and focus on it with javascript. - Aaron --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Aaron Brown wrote:> John Butler wrote: >> Im updating a scrollable div with many links_to_remote. If a user has >> scrolled half way down the div and then clicks the link_to_remote >> outside the div it then updates the scrollable div but stays half way >> down. I want it to automatically go back to the top of the div. > > Perhaps you could do a javascript "focus" on an element at the top of > the div in question? I haven''t tried it, so no guarantees, but it may > work. > > Similar to having <a name="top"></a> for use with links that hop around > the page (common usage for FAQ pages), you could make an empty <a> tag > with id="top" and focus on it with javascript. > > - AaronThanks for your help, I created an invisible link at the top of the div and after i update the scrollable div i call the code below at the end of the partial: <%= javascript_tag render(:update) { |page| page[''top''].focus } %> JB -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---