Event delegation is coming in the next version of MooTools. If you use your
method below it should still work in the next version of MooTools, but the
official mechanism is quite different...

On Wed, Apr 1, 2009 at 12:24 AM, eskimoblood (via Nabble) <
[email protected]<ml-user%[email protected]>
> wrote:

>
> 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 
> <jacob.far...@...<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2567584&i=0>>
> wrote:
> > I think I found my answer - I can simply use var blah = new Event
> > (rawEvent).
> >
> > On Mar 31, 11:36 pm, Jacob 
> > <jacob.far...@...<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2567584&i=1>>
> 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
>
>
> ------------------------------
>  View message @
> http://n2.nabble.com/-Moo--Event-delegation-for-focus-and-blur-tp2566948p2567584.html
> To start a new topic under MooTools Users, email
> [email protected]<ml-node%[email protected]>
> To unsubscribe from MooTools Users, click here< (link removed) >.
>
>
>


-----
The MooTools Tutorial:  http://www.mootorial.com www.mootorial.com 
Clientcide:  http://www.clientcide.com www.clientcide.com 
-- 
View this message in context: 
http://n2.nabble.com/-Moo--Event-delegation-for-focus-and-blur-tp2566948p2567684.html
Sent from the MooTools Users mailing list archive at Nabble.com.

Reply via email to