I'll take a shot at that as I've been using some custom events in components
being built and it'd be a nice behavior to have. And allow for a decoupling
of callbacks that we have with developers currently.
Cheers,
-js
On 10/17/07, Jörn Zaefferer <[EMAIL PROTECTED]> wrote:
>
>
> Jonathan Sharp schrieb:
> > $(window)
> > .bind('testEvent', function(e) {
> > alert('1');
> > e.stopPropagation();
> > e.preventDefault();
> > return false;
> > })
> > .bind('testEvent', function() {
> > alert('2');
> > })
> > .trigger('testEvent');
> >
> > The above code doesn't stop the testEvent from triggering the second
> > alert. Is the propagation prevention just for standard events such as
> > 'click', etc.?
> Yep. jQuery makes no attempt to implement any of those two for custom
> events. But its an interesting idea and not too hard to implement.
>
> If you want to give an implementation a try, you'd have to start at this
> line:
>
> data.unshift( this.fix({ type: type, target: element }) );
>
> You could provide implementations for preventDefault and stopPropagation
> here.
>
> The jQuery.event.handle method would have to be modified to check if one
> of those two was called and cancel event handling when dealing with
> triggered events.
>
> -- Jörn
>