We have created a "modal" dialog box that limits the user''s access to the page beneath. However, a user can still tab through the page''s input and link elements. We''ve been asked to prevent this behavior and force the tab order to cycle through only those inputs and links visible on the dialog box. This is what I''ve done so far: function showPopup(popUpId) { ... // irrelevent code ommitted document.observe(''focus'', function(evt) { var focusedElement = evt.element(); if (!focusedElement.descendantOf(popUpId) ) { var targetElement = $(popUpId).down(''input''); targetElement.focus(); targetElement.scrollTo(); } }); $(popUpId).show(); } This _almost_ works. Since it is observing the focus event, a link underneath the overlay actually gets the focus. My code successfully sets focus to the first input in the popup, then it scrolls to it. This is when it breaks. The browser then scrolls down to the location of the formerly focused link. I''ve tried various combinations of Event.stop(), but I can''t seem to prevent this default behavior. Can anyone suggest a way to stop the scroll or a better strategy for accomplishing this modal behavior? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Apr 5, 6:57 am, James <JamesJReyno...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> We have created a "modal" dialog box that limits the user''s access to > the page beneath. However, a user can still tab through the page''s > input and link elements. We''ve been asked to prevent this behavior > and force the tab order to cycle through only those inputs and links > visible on the dialog box.Disable the controls not in the dialog - disabled controls don''t get focus. When the dialog is dismissed, re-enable them. -- Rob --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> Disable the controls not in the dialog - disabled controls don''t get > focus.That was my first thought when reading his post, but it was the links that stopped me (and so I was interested to see answers in this thread). I don''t think you can disable links in the usual way; do you have a reference for a good way to do it? The only way I''ve seen (and I haven''t looked hard) is setting the onclick handler on the link to return false, which probably makes the link nonfunctional, but not actually *disabled*... -- T.J. Crowder tj / crowder software / com On Apr 5, 1:13 pm, RobG <rg...-AFFH1GffN5hPR4JQBCEnsQ@public.gmane.org> wrote:> On Apr 5, 6:57 am, James <JamesJReyno...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > We have created a "modal" dialog box that limits the user''s access to > > the page beneath. However, a user can still tab through the page''s > > input and link elements. We''ve been asked to prevent this behavior > > and force the tab order to cycle through only those inputs and links > > visible on the dialog box. > > Disable the controls not in the dialog - disabled controls don''t get > focus. When the dialog is dismissed, re-enable them. > > -- > Rob--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Apr 5, 10:54 pm, "T.J. Crowder" <tjcrow...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Disable the controls not in the dialog - disabled controls don''t get > > focus. > > That was my first thought when reading his post, but it was the links > that stopped me (and so I was interested to see answers in this > thread).Sorry, I missed the links bit. You can set their visibility to hidden, then show them again. Your problem is that the browser itself controls what happens when a key is pressed, you can only interfere with it to the extent you are allowed, which may be different and require different handling depending on the browser. -- Rob --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I''m liking your idea about hiding the links. That''s an easy way to deal with it. I think I''ll increase the opacity of the overlay so as to disguise the missing links and see how it looks. Thanks! On Apr 5, 3:43 pm, RobG <rg...-AFFH1GffN5hPR4JQBCEnsQ@public.gmane.org> wrote:> On Apr 5, 10:54 pm, "T.J. Crowder" <tjcrow...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Disable the controls not in the dialog - disabled controls don''t get > > > focus. > > > That was my first thought when reading his post, but it was the links > > that stopped me (and so I was interested to see answers in this > > thread). > > Sorry, I missed the links bit. You can set their visibility to > hidden, then show them again. Your problem is that the browser itself > controls what happens when a key is pressed, you can only interfere > with it to the extent you are allowed, which may be different and > require different handling depending on the browser. > > -- > Rob--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Oops! I forgot about the div elements. They will also take focus when tabbing around a page. If I start hiding them, I may as well make the page completely opaque. Fortunately, the default behavior really isn''t a big deal in our case. Thanks for your suggestions! On Apr 7, 9:27 am, James <JamesJReyno...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m liking your idea about hiding the links. That''s an easy way to > deal with it. I think I''ll increase the opacity of the overlay so as > to disguise the missing links and see how it looks. > > Thanks! > > On Apr 5, 3:43 pm, RobG <rg...-AFFH1GffN5hPR4JQBCEnsQ@public.gmane.org> wrote: > > > On Apr 5, 10:54 pm, "T.J. Crowder" <tjcrow...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Disable the controls not in the dialog - disabled controls don''t get > > > > focus. > > > > That was my first thought when reading his post, but it was the links > > > that stopped me (and so I was interested to see answers in this > > > thread). > > > Sorry, I missed the links bit. You can set their visibility to > > hidden, then show them again. Your problem is that the browser itself > > controls what happens when a key is pressed, you can only interfere > > with it to the extent you are allowed, which may be different and > > require different handling depending on the browser. > > > -- > > Rob--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---