jquery/jquery — comment on commit 24e416dca36df4b182a612dba37f8b6cdaa25916
File:  line 0
By dmethvin:

Hi Julian,

First, thanks for being understanding about this! It's always painful to
change library code in a way that might break clients, and that's why we're
asking.

For that particular case, you might look into the event.special._default
method that can be set for any special event name. If none of the handlers
calls event.preventDefault(), that handler can do whatever it needs. So in
your case it sounds like the other clients (or your wrapper around them)
could call event.preventDefault() and if nobody did that your special
_default handler would be called.

There have been some changes to the special events model in 1.7, and I will
be tweaking it a bit in 1.7.1 to fix a few things. Let me know if your code
still works.

On Wed, Nov 2, 2011 at 10:29 AM, julianjelfs <
reply@reply.github.com>wrote:

> We have a javascript event aggregator component in our application so that
> unrelated components can publish and subscribe as means of maintaining a
> loose coupling between the components. We use jQuery custom event binding
> under the hood to achieve this. There are some rare circumstances where a
> component must only subscribe to an event if nothing else has subscribed to
> it. So we implemented a sort of isSubscribed function on our event
> aggregator. Under the hood this delves into the data("events") to work out
> the answer. I did this in the full understanding that it was dodgy and that
> I was running the risk of it breaking but it works for me at the moment and
> satisfies a requirement. If there were some sort of hasEvent thing, it
> would also solve my problem. I'm pretty sure I could work out some other
> way to do it, but for me it's a +1 for hasEvent.
>
> --
> Reply to this email directly or view it on GitHub:
>
> https://github.com/jquery/jquery/commit/24e416dca36df4b182a612dba37f8b6cdaa25916#commitcomment-690274
>