Supposedly Prototype extends the HTMLFormElement.prototype so that the following code ought to work $(''myform'').focusFirstElement() Strangely, it does not work in Firefox 2.0. It complains that focusFirstElement is not a function. Firebug tells me that HTMLFormElement.prototype.focusFirstElement indeed is a function. I can''t say I understand what''s happening here. Michael -- Michael Schuerig mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org http://www.schuerig.de/michael/ --~--~---------~--~----~------------~-------~--~----~ 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 Friday 19 January 2007 13:56, Michael Schuerig wrote:> Supposedly Prototype extends the HTMLFormElement.prototype so that > the following code ought to work > > $(''myform'').focusFirstElement() > > Strangely, it does not work in Firefox 2.0. It complains that > focusFirstElement is not a function.Well, select is not broken and neither is focusFirstElement(). Unfortunately, in my concrete case it is. I''ll have to find out and when it''s something interesting or very dumb on my part, I''ll follow up. Michael -- Michael Schuerig mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org http://www.schuerig.de/michael/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Michael Schuerig wrote:> Supposedly Prototype extends the HTMLFormElement.prototype so that the > following code ought to work > > $(''myform'').focusFirstElement()The function in Prototype.js should provide a hint: focusFirstElement: function(form) { ... } Which indicates it requires a form as an argument. Try: focusFirstElement(''myform''); Which works in Firefox but fails in Safari. You might prefer the much more widely supported: document.forms[''myform''].elements[0].focus(); or, if the form''s name is myform you can use the shorter: document.myform.elements[0].focus(); -- 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 Saturday 20 January 2007 16:20, RobG wrote:> Michael Schuerig wrote: > > Supposedly Prototype extends the HTMLFormElement.prototype so that > > the following code ought to work > > > > $(''myform'').focusFirstElement() > > The function in Prototype.js should provide a hint: > > focusFirstElement: function(form) { ... } > > > Which indicates it requires a form as an argument. Try: > > focusFirstElement(''myform'');Nope. The functions in Form.Methods are mixed into HTMLFormElement.prototype, where possible, otherwise they are added to each form accessed through $(''myform''). Therefore $(''myform'').focusFirstElement() does indeed work. That it didn''t work for me originally was due to some braindeadness on my part. Let''s say when ''myform'' is really the id of a form element, then it does work at least in Firefox, Konqueror, and IE7. Michael -- Michael Schuerig mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org http://www.schuerig.de/michael/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---