Hi all, I''m trying to simply move the focus programmatically, but cannot make it work. Goal: move the focus to the div that receives the ''mouseover'' The problem: the focus does not move (stays in a form field,on top of the page) Here is a simplified version of the code that does not work: Event.addBehavior({ ''div.item'': function() { this.observe(''focus'', function() { this.addClassName(''focus_on'');}); this.observe(''blur'' , function() { this.removeClassName(''focus_on''); }); this.observe(''mouseover'', function() { this.addClassName(''hovering''); <<<<--- WORKS FINE this.focus(); <<<--------- HAS NO EFFECT }); } }); TIA Alain --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
You can''t add focus to a div. Only windows and form elements, unless I''m mistaken. On 5/22/07, Alain Ravet <alain.ravet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Hi all, > > I''m trying to simply move the focus programmatically, but cannot make > it work. > Goal: move the focus to the div that receives the ''mouseover'' > The problem: the focus does not move (stays in a form field,on top of > the page) > > Here is a simplified version of the code that does not work: > > Event.addBehavior({ > ''div.item'': function() { > this.observe(''focus'', function() { > this.addClassName(''focus_on'');}); > this.observe(''blur'' , function() { > this.removeClassName(''focus_on''); }); > this.observe(''mouseover'', function() { > this.addClassName(''hovering''); <<<<--- WORKS FINE > this.focus(); <<<--------- HAS NO EFFECT > }); > } > }); > > > > TIA > > Alain > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Jerod, > You can''t add focus to a div. Only windows and form elements, > unless I''m mistaken. I can move the focus to the div with TAB (I know it works because I observe this event, and change the border of the div when it happens. see O.P.) So, I guess it should be doable programmatically. (Ultimately, I want to reproduce gmail and Google reader like navigation, where you can move to the prev/next item by pressing a key, and I suppose it means moving the focus to the target item.) Alain -- Alain Ravet -------- http://blog.ravet.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Alain Ravet wrote:> Jerod, > > > You can''t add focus to a div. Only windows and form elements, > > unless I''m mistaken. > > I can move the focus to the div with TAB (I know it works because I > observe this event, and change the border of the div when it happens. > see O.P.) > So, I guess it should be doable programmatically. > > > (Ultimately, I want to reproduce gmail and Google reader like > navigation, where you can move to the prev/next item by pressing a > key, and I suppose it means moving the focus to the target item.) > > > Alain > > >Can you give a URL with a working example? Does it behave the same in all browsers? I too have only seen TAB change focus on form elements and links and I thought that the "focus" event only fired for form elements and windows. --Ken Snyder --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Ken, > .. Does it behave the same in > all browsers? I too have only seen TAB change focus on form elements > and links and I thought that the "focus" event only fired for form > elements and windows. You''re right, I noticed this behaviour in Firefox only. As each div I want to move the focus to also contains a link, I solved my problem by moving the focus to the link, instead of the containing div. It was simple after all. Alain --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---