That's what jQuery.Bubble is for

http://plugins.jquery.com/project/Bubble

Cheers

--
Ariel Flesler
http://flesler.blogspot.com

On 22 nov, 23:46, "Jeffrey Kretz" <[EMAIL PROTECTED]> wrote:
> Do you know if this plays friendly with the jQuery event model?  
>
> Looking through the source code, it has its own implementation of "fix" for
> events, along with its own data storage for event handlers.
>
> Without testing it, I would tend to think these two libraries wouldn't jam
> up and cause a mess.
>
> You implement a jquery-based solution using a pattern like this:
>
> jQuery.fn.bubble = function(type) {
>
>    return this.each(function(i){
>
>       // Build a fake event, and assign the target==this.
>       var evt = ....;
>       evt.target = this;
>
>       var el = this;
>       while (el) {
>
>          // Look for a handler of the supplied type.
>          var handler = ....;
>
>          if (handler)
>          {
>             handler.apply(parent,[evt]);
>             break;
>          }
>          else
>             el = el.parentNode;
>       }
>
>    });
>
> };
> -----Original Message-----
> From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
>
> Behalf Of ricardobeat
> Sent: Saturday, November 22, 2008 4:44 PM
> To: jQuery (English)
> Subject: [jQuery] Re: event delegation - great, but how does one trigger the
> handlers through code?
>
> You're right, it doesn't work.
>
> Maybe NW Events could help here:http://code.google.com/p/nwevents/
>
> It's an event manager and it can fire/propagate 'fake' events.
>
> - ricardo
>
> On Nov 22, 7:32 pm, "Jeffrey Kretz" <[EMAIL PROTECTED]> wrote:
> > I pretty sure it won't, because click() will fire trigger(), which will
> use
> > data() to lookup the bound event of the selected element, and not find
> > anything.
>
> > Haven't tested this though.
>
> > JK
>
> > -----Original Message-----
> > From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
>
> > Behalf Of ricardobeat
> > Sent: Saturday, November 22, 2008 7:43 AM
> > To: jQuery (English)
> > Subject: [jQuery] Re: event delegation - great, but how does one trigger
> the
> > handlers through code?
>
> > Can't you just $('tbody td:eq(x)').click() ? The event should
> > propagate as normal and reach the tbody. I guess.
>
> > On Nov 22, 1:11 am, Leeoniya <[EMAIL PROTECTED]> wrote:
> > > During event delegation, handlers are registered higher in the DOM
> > > tree and then filtered when the event is triggered. This is great if
> > > you have 2000 td/th cells, you can attach a listener to tbody and
> > > filter down. But would i trigger the event programatically? Since the
> > > handler isnt actually registered on the td cells, i cant figure out a
> > > way to do this except maybe construct a fake event with the source
> > > element by hand and pass it into the handler somehow??
>
> > > this is the biggest drawback to delegation that i have run into, it
> > > would be great to find a good way to manually trigger these events -
> > > if anyone has some advice, please share.
>
> > > thanks,
> > > Leon

Reply via email to