> Here's what
> I was thinking of, untested:
>
> $(document).bind("myEvent", subscriber_element, function(event) {
>     alert("I received an event without subscribing!");
>     alert("my node type is "+event.data.nodeType);
>
> });
>
> $(document).trigger("myEvent");
>
> The basic idea is to pass the subscribing element as the data allowed
> in the bind operation, then pull it out in the event handler as
> event.data. If you need to pass more context, the data could be an
> array or object of stuff instead of a bare DOM object.

Thanks.  That looks perfect.  I assume that I can bind multiple
myEvents to document and when myEvent is triggered every one of the
functions bound using myEvent will execute with the data that was in
the bind call for that function.
I can have any object register for any event without telling anyone
else and any number of senders can send that event.  Nobody has to
register anything with anybody else.  What could be more powerful than
that?

I can see where I could build a framework that does exactly this, but
that is the great thing about jQuery.  It is already there.

Reply via email to