By the way, here's a quick html page to show it in action:
http://pastie.caboo.se/149394

On Feb 8, 2:17 pm, Pat Nakajima <[EMAIL PROTECTED]> wrote:
> Hey, after reading up a bit about event delegation vs. event handling
> (http://icant.co.uk/sandbox/eventdelegation), I put together this
> little bit:
>
>   Object.extend(Event, {
>     delegate: function(element, eventName, targetSelector, handler) {
>       var element = $(element);
>       element.observe(eventName, function(event){
>         var origin = $(event.target);
>         if ( origin.match(targetSelector) ){
>           return handler(event);
>         } else {
>           event.stop();
>         }
>       })
>     }
>   })
>
>   var ElementExtensions = {
>     delegate: Event.delegate
>   }
>
>   Element.addMethods(ElementExtensions);
>
> Now, I'm not the foremost expert on Prototype's event handling, but I
> thought this was a nice little bit of syntactic sugar, and it seems to
> work well enough. Do you think it's fit for core? (If so, I'd love to
> clean it up and write some tests)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to