This is the way I've done it for all events, but you have to use a
classname as an idendifier:

Element.implement({
        /**
         * @param {String} eventTyp
         * @param {String} className
         * @param {Function} func
         */
        registerEvent: function(eventTyp, className, func){
                var savedEvents = this.retrieve('savedEvents') || {};
                if (!savedEvents[eventTyp]) {
                        if (eventTyp == 'blur') {
                                if (Browser.Engine.trident) {
                                        this.onfocusout = 
this.handleEvents.bind(this);
                                } else {
                                        this.addEventListener('blur', 
function(e){this.handleEvents
(e)}.bind(this), true );
                                }
                        } else {
                                this.addEvent(eventTyp, 
this.handleEvents.bindWithEvent(this));
                        }
                        savedEvents[eventTyp]={};
                }
                savedEvents[eventTyp][className] = func;
                this.store('savedEvents', savedEvents);
                return this;
        },
        handleEvents: function(event){
                var storedEvents = 
this.retrieve('savedEvents')[(!event.type.match(/
DOMMouseScroll|focusout/)) ? event.type : event.type ==
'DOMMouseScroll' ? 'mousewheel' : 'blur'];
                if (storedEvents) {
                        var target = $(event.target),
                                eventIsFired = false;
                        while (!eventIsFired && target) {
                                target.className.split(' 
').some(function(className){
                                        if (storedEvents[className]) {
                                                event.target = target;
                                                
storedEvents[className].run(event);
                                                eventIsFired = true;
                                                return true;
                                        }
                                }, this);
                                target = target.getParent();
                        }
                }
        }
});


On 1 Apr., 05:50, Jacob <[email protected]> wrote:
> I think I found my answer - I can simply use var blah = new Event
> (rawEvent).
>
> On Mar 31, 11:36 pm, Jacob <[email protected]> wrote:
>
> > So im trying to learn about effective event delegation, and I need to
> > know when certain elements lose and gain focus.
>
> > PPK wrote a great article on this, (http://www.quirksmode.org/blog/
> > archives/2008/04/delegating_the.html) and I was wondering about his
> > solution:
>
> > How can I properly use Internet Explorerer's onfocusin/onfocusout
> > events and addEventListener so that this concept works smoothly cross-
> > browser, just like the existing Mootools addEvent system? Do I need to
> > do some major extending to the Mootools Event object?
>
> > Thanks
> > Jacob

Reply via email to