broberts
2008-Feb-13 21:18 UTC
Element.focusFirstElement() causing issue with Element.addMethods()
Prototype 1.6.0.2 Internet Explorer 7 I''ve found that when I call $(''myform'').focusFirstElement(); to set focus on the first field in my form, that this statement "wrecks" the extensions I''ve added using Element.addMethods() if it executes before Element.addMethods(). When I try to call one of my exenstions, the IE7 JavaScript interpreter throws an error as follows: "Object does not support this property or method." It works fine in Firefox 2.x Here''s an actual example... <html> <head> <title>Simple Page</title> <script src="prototype.js" type="text/javascript" language="JavaScript"></script> </head> <body> <form name="myform" id="myform"> <input type="text" name="myinput" id="myinput" value="" size="10" onclick="$(this).myCustomExtension();" /> </form> <script type="text/javascript" language="JavaScript"> var myExtensions = { myCustomExtension: function(element){ alert(''It\''s working!''); } } // If this focusFirstElement() statement executes before the subsequent Element.addMethods() statement, IE7 is // unable to resolve the name of my extension $(''myform'').focusFirstElement(); // This statement does NOT throw a JavaScript error, but when the onclick event fires // for ''myinput'', IE7 will not able to resolve the name of my custom extension and the // javascript interpreter will throw an error Element.addMethods(''input'', myExtensions); </script> </body> </html> Again, this only happens in Internet Explorer 7. In this simple example, I can place the Element.addMethods() statement before the focusFirstElement() and all is good, but it''s not so easy when all my extensions are being loaded when the ''load'' event fires on the window object. Has anyone else experienced this problem? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Reasonably Related Threads
- Adding my own extensions with Elements.addMethods()
- Element.addMethods vs extending prototype.
- Prototype: focusFirstElement and tabindex -1 ?
- Element.addMethods functions swallowing exceptions (IE6 + 7)
- Element.addMethods() is not a function after upgrade to 1.7.0