Hi, I''ve just had my very first attempt of making a JavaScript class, "prototype" style, so please bare with me, for any disastrous errors :-) Anyway, I''ve made this class, which is called on an input field on focus: http://pastebin.com/487417 It works fine in FireFox, but causes some problems in IE. My question is regarding line 69 in the paste. What is the right way of "re-attaching" the event to the element? I.e. once it is focused again, the class should fire again. As I said, it works fine, both in FF, but once I clone the object in IE, the new object somehow does not include this class. It does in firefox though. Why is that? I''ve tried alerting the onfocus function, which has a "function anonymous() {}" around the original function, could this be the problem? And if so, how could it be solved? Thanks in advance for your attention to this matter. Best Regards Michael. _____ Jeg beskyttes af den gratis SPAMfighter til privatbrugere. Den har indtil videre sparet mig for at fa 320 spam-mails Betalende brugere far ikke denne besked i deres e-mails. Hent en gratis SPAMfighter her <http://www.spamfighter.com/Lang_DA/Product_Info.asp> . _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
You might want to try: Event.observe(this.elm, ''focus'', this.onFocus.bindAsEventListener(this)); That''s just at a cursory glance. If it still doesn''t work, I could look into it more. Greg ________________________________ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Michael Ladum Sent: Monday, January 02, 2006 11:42 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails-spinoffs] First time class problems Hi, I''ve just had my very first attempt of making a JavaScript class, "prototype" style, so please bare with me, for any disastrous errors :-) Anyway, I''ve made this class, which is called on an input field on focus: http://pastebin.com/487417 It works fine in FireFox, but causes some problems in IE. My question is regarding line 69 in the paste. What is the right way of "re-attaching" the event to the element? I.e. once it is focused again, the class should fire again. As I said, it works fine, both in FF, but once I clone the object in IE, the new object somehow does not include this class. It does in firefox though. Why is that? I''ve tried alerting the onfocus function, which has a "function anonymous() {}" around the original function, could this be the problem? And if so, how could it be solved? Thanks in advance for your attention to this matter. Best Regards Michael. ________________________________ Jeg beskyttes af den gratis SPAMfighter til privatbrugere. Den har indtil videre sparet mig for at få 320 spam-mails Betalende brugere får ikke denne besked i deres e-mails. Hent en gratis SPAMfighter her <http://www.spamfighter.com/Lang_DA/Product_Info.asp> . _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Oh, and if I''m looking at the right code, this.onFocus just calls this.elm.onfocus, so it shouldn''t work at all it seems. Am I missing something? Greg ________________________________ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Gregory Hill Sent: Monday, January 02, 2006 12:44 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails-spinoffs] First time class problems You might want to try: Event.observe(this.elm, ''focus'', this.onFocus.bindAsEventListener(this)); That''s just at a cursory glance. If it still doesn''t work, I could look into it more. Greg ________________________________ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Michael Ladum Sent: Monday, January 02, 2006 11:42 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails-spinoffs] First time class problems Hi, I''ve just had my very first attempt of making a JavaScript class, "prototype" style, so please bare with me, for any disastrous errors :-) Anyway, I''ve made this class, which is called on an input field on focus: http://pastebin.com/487417 It works fine in FireFox, but causes some problems in IE. My question is regarding line 69 in the paste. What is the right way of "re-attaching" the event to the element? I.e. once it is focused again, the class should fire again. As I said, it works fine, both in FF, but once I clone the object in IE, the new object somehow does not include this class. It does in firefox though. Why is that? I''ve tried alerting the onfocus function, which has a "function anonymous() {}" around the original function, could this be the problem? And if so, how could it be solved? Thanks in advance for your attention to this matter. Best Regards Michael. ________________________________ Jeg beskyttes af den gratis SPAMfighter til privatbrugere. Den har indtil videre sparet mig for at få 320 spam-mails Betalende brugere får ikke denne besked i deres e-mails. Hent en gratis SPAMfighter her <http://www.spamfighter.com/Lang_DA/Product_Info.asp> . _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs