> If the events went to "document", how
> would I dispatch them on to the desired object?  I would have to
> register receiver objects with the code attached to "document" which
> would seem to me to be an indirect alternative to just registering
> with the sending object, which I was hoping to avoid.

Sorry, I was just being lazy and didn't show enough code. 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.

Reply via email to