Fire custom events vs delegation #2484

inkstak opened this Issue Mar 26, 2013 · 3 comments

3 participants



Am trying to play with delegations and custom events, but no way to catch them.

$(document.body).addEvent('show:relay(div)', function() {
  $$('pre').appendText("relay show\n");

$$('div').setStyle('display', 'block').fireEvent('show')

Should I have to pass an event object when firing the custom event ?
You can get a Fiddle here :


Your example shows that you have two show event handlers attached div elements and document.body element.

In order to trigger the show delegated event on the document.body you must fire the event on the object, and pass it the correct arguments. Here's the example working with delegated events:

As you can see, the event object from anchors click event (not delegated) and the div element is passed as arguments to fireEvent method of the document.body. I hope this helps.

If this works, please close the ticket.



Thanks for your answer (I just saw it today, with 2 months late).
You're solution is right. that means the issue can be closed.

However, I suggest to update the docs on about how linking delegation and FireEvent.

@inkstak inkstak closed this Jun 17, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment