broberts
2008-Mar-26 20:37 UTC
Form.Element.disable() shifts focus in some browsers...why?
I''ve found in Firefox 2.x, using Form.Element.disable() shifts the focus from the current form element somewhere else in the document (possibly to the disabled form element right before it''s disabled). The effect is that the BLUR event is fired on the current form element when Form.Element.disable() is invoked and it doesn''t seem that focus should have ever left the current form element. In IE7, this does not happen. Any ideas? For example... <form action="" method="post" name="myForm" id="myForm"> <input type="button" name="myButton" id="myButton" value="Click Me" /><br /><input type="text" name="myTextBox" id="myTextBox" value="" onblur="alert(''Focus left!'');" onkeyup="$(''myButton'').disable();" /> </form> Help! What can I do to prevent the current form element from ever losing focus in Firefox 2.x? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
kangax
2008-Mar-26 20:55 UTC
Re: Form.Element.disable() shifts focus in some browsers...why?
You could apply this patch http://dev.rubyonrails.org/ticket/11214 - kangax On Mar 26, 4:37 pm, broberts <brobert...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''ve found in Firefox 2.x, using Form.Element.disable() shifts the > focus from the current form element somewhere else in the document > (possibly to the disabled form element right before it''s disabled). > > The effect is that the BLUR event is fired on the current form element > when Form.Element.disable() is invoked and it doesn''t seem that focus > should have ever left the current form element. > > In IE7, this does not happen. Any ideas? For example... > > <form action="" method="post" name="myForm" id="myForm"> > > <input type="button" name="myButton" id="myButton" value="Click Me" / > > ><br /> > > <input type="text" name="myTextBox" id="myTextBox" value="" > onblur="alert(''Focus left!'');" onkeyup="$(''myButton'').disable();" /> > > </form> > > Help! What can I do to prevent the current form element from ever > losing > focus in Firefox 2.x?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Justin Perkins
2008-Mar-26 20:59 UTC
Re: Form.Element.disable() shifts focus in some browsers...why?
On Wed, Mar 26, 2008 at 3:55 PM, kangax <kangax-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > You could apply this patch http://dev.rubyonrails.org/ticket/11214I guess I misunderstood the question, I thought the complaint was that an element that had focus, was then disabled and thereby lost focus and the author of this question did not want a disabled form element to lose focus. I answered this in his other, duplicate post. -justin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
broberts
2008-Mar-26 21:04 UTC
Re: Form.Element.disable() shifts focus in some browsers...why?
Justin, Kangax is on the money with his response. Form.Element.disable() is stealing focus from the current form element. On Mar 26, 3:59 pm, "Justin Perkins" <justinperk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Wed, Mar 26, 2008 at 3:55 PM, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > You could apply this patchhttp://dev.rubyonrails.org/ticket/11214 > > I guess I misunderstood the question, I thought the complaint was that > an element that had focus, was then disabled and thereby lost focus > and the author of this question did not want a disabled form element > to lose focus. > > I answered this in his other, duplicate post. > > -justin--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
broberts
2008-Mar-26 21:06 UTC
Re: Form.Element.disable() shifts focus in some browsers...why?
Kangax, In this case, "applying a patch" is synonymous with "modify the source code [of Prototype]", correct? On Mar 26, 3:55 pm, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You could apply this patchhttp://dev.rubyonrails.org/ticket/11214 > > - kangax > > On Mar 26, 4:37 pm, broberts <brobert...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I''ve found in Firefox 2.x, using Form.Element.disable() shifts the > > focus from the current form element somewhere else in the document > > (possibly to the disabled form element right before it''s disabled). > > > The effect is that the BLUR event is fired on the current form element > > when Form.Element.disable() is invoked and it doesn''t seem that focus > > should have ever left the current form element. > > > In IE7, this does not happen. Any ideas? For example... > > > <form action="" method="post" name="myForm" id="myForm"> > > > <input type="button" name="myButton" id="myButton" value="Click Me" / > > > ><br /> > > > <input type="text" name="myTextBox" id="myTextBox" value="" > > onblur="alert(''Focus left!'');" onkeyup="$(''myButton'').disable();" /> > > > </form> > > > Help! What can I do to prevent the current form element from ever > > losing > > focus in Firefox 2.x?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
broberts
2008-Mar-26 21:19 UTC
Re: Form.Element.disable() shifts focus in some browsers...why?
Kangax, Do you know if this patch be incorporated into future Prototype versions? On Mar 26, 3:55 pm, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You could apply this patchhttp://dev.rubyonrails.org/ticket/11214 > > - kangax > > On Mar 26, 4:37 pm, broberts <brobert...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I''ve found in Firefox 2.x, using Form.Element.disable() shifts the > > focus from the current form element somewhere else in the document > > (possibly to the disabled form element right before it''s disabled). > > > The effect is that the BLUR event is fired on the current form element > > when Form.Element.disable() is invoked and it doesn''t seem that focus > > should have ever left the current form element. > > > In IE7, this does not happen. Any ideas? For example... > > > <form action="" method="post" name="myForm" id="myForm"> > > > <input type="button" name="myButton" id="myButton" value="Click Me" / > > > ><br /> > > > <input type="text" name="myTextBox" id="myTextBox" value="" > > onblur="alert(''Focus left!'');" onkeyup="$(''myButton'').disable();" /> > > > </form> > > > Help! What can I do to prevent the current form element from ever > > losing > > focus in Firefox 2.x?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
jdalton
2008-Mar-26 21:25 UTC
Re: Form.Element.disable() shifts focus in some browsers...why?
The patch has been sent to the core team, its up to them to commit it to the source of prototype. Until then you can modify your prototype.js (its only a 1 line removal). --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
broberts
2008-Mar-26 21:54 UTC
Re: Form.Element.disable() shifts focus in some browsers...why?
Great. Thanks. Please understand that I''m not complaining about having to modify the script now and in future versions. Obviously, one line of code isn''t any big deal. However, I just wanted to anticipate the time when making this modification won''t be necessary. On Mar 26, 4:25 pm, jdalton <John.David.Dal...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> The patch has been sent to the core team, its up to them to commit it > to the source of prototype. > Until then you can modify your prototype.js (its only a 1 line > removal).--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Justin Perkins
2008-Mar-26 22:11 UTC
Re: Form.Element.disable() shifts focus in some browsers...why?
As noted in that trac ticket, simply removing the call to blur is a somewhat poor solution to the problem. If you have other event observers that are listening for the blur event, this can have an undesirable effect. Making sure that the element you''re about to disable currently has focus, before firing the blur event is the correct approach to take. -justin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
broberts
2008-Mar-26 22:40 UTC
Re: Form.Element.disable() shifts focus in some browsers...why?
Justin, Thanks. Yes, but as Kangax goes on to say in the trac ticket..."There''s no native way to check if element has focus. It can be done programatically - using focus/blur events (to keep track of element''s state), but that''s quite problematic in this case." On Mar 26, 5:11 pm, "Justin Perkins" <justinperk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> As noted in that trac ticket, simply removing the call to blur is a > somewhat poor solution to the problem. If you have other event > observers that are listening for the blur event, this can have an > undesirable effect. > > Making sure that the element you''re about to disable currently has > focus, before firing the blur event is the correct approach to take. > > -justin--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---