I know this is a bug / behavior in Internet Explorer, but I was hoping that a fix could be put into Prototype to make it work. I've tried doing it myself based on some code I found, but I'm having problems getting it working so I need some help.
The problem is that Internet Explorer will call functions that are attached to the same element and event type in random order instead of the order in which they were added. For example, if I register the following functions: Event.observe(window, 'load', blah1); Event.observe(window, 'load', blah2); Event.observe(window, 'load', blah3); the functions can be called in any order in IE. So, a likely solution would be to call one function that calls all the other functions in order. So here was the code I found that someone suggested (the changed parts are commented out): Object.extend(Event, { ... observers: false, _observeAndCache: function(element, name, observer, useCapture) { if (!this.observers) this.observers = []; if (element.addEventListener) { this.observers.push([element, name, observer, useCapture]); element.addEventListener(name, observer, useCapture); } else if (element.attachEvent) { this.observers.push([element, name, observer, useCapture]); //element.attachEvent('on' + name, observer); element.attachEvent('on' + name, this._observeIE); } }, //Added _observeIE: function(e) { Event.observers.each( function(observer) { if (e.srcElement == observer[0]) observer[2].call(this, e); }.bind(this) ); }, ... stopObserving: function(element, name, observer, useCapture) { element = $(element); useCapture = useCapture || false; if (name == 'keypress' && (navigator.appVersion.match(/Konqueror|Safari|KHTML/) || element.detachEvent)) name = 'keydown'; if (element.removeEventListener) { element.removeEventListener(name, observer, useCapture); } else if (element.detachEvent) { try { //element.detachEvent('on' + name, observer); element.detachEvent('on' + name, this._observeIE); } catch (e) {} } } }); The problem with this is... it never calls any of my functions. So I took a look at e.srcElement inside _observeIE with an alert, and it's saying that's e.srcElement is null. I don't know why. So I thought, maybe window events have a null for their source element, but that wasn't the case; it's null for every event on every element. So hopefully someone has some suggestions. Thanks, Matt --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---