<html> <head> <title>Order of Events</title> <script src="javascripts/prototype.js" type="text/javascript"></ script> </head> <body> <script type="text/javascript"> function fCall1() { alert(''Call 1''); } function fCall2() { alert(''Call 2''); } function fCall3() { alert(''Call 3''); } Event.observe(window, ''load'', fCall1, false); Event.observe(window, ''load'', fCall2, false); Event.observe(window, ''load'', fCall3, false); </script> <form id="form1"> Order of Event Test </form> </body> </html> Using above code, I get different order of event firing in IE and Firefox Firefox: 1,2,3 but in IE(weird): 2,3,1 how can I get the same order in both IE and Firefox. Thanks, :-Uday --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
||__Uday__|| wrote:> ... > Event.observe(window, ''load'', fCall1, false); > Event.observe(window, ''load'', fCall2, false); > Event.observe(window, ''load'', fCall3, false); > ... > Using above code, I get different order of event firing in IE and > Firefox > Firefox: 1,2,3 but in > IE(weird): 2,3,1 > > how can I get the same order in both IE and Firefox. >I believe the order for attached events is by specification _not guaranteed_. Event.observe() uses the DOM methods attachEvent and addEventListener. If you need a guaranteed order, you''ll have to attach a function that calls the three in succession. e.g. function fCallAll() { fCall1(); fCall2(); fCall3(); } Event.observe(window, ''load'', fCallAll); If you don''t know which functions need to be called, you could create a wrapper class to fire events more generally. A myriad of ways exist. Here are some full featured event classes: http://encytemedia.com/blog/articles/2006/02/08/working-with-events-in-prototype http://livepipe.net/projects/object_event/ http://www.truerwords.net/articles/web-tech/custom_events.html -- Ken Snyder --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks Ken, your reply was so helpful. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---