...

View Full Version : Custom Event Attributes



nolachrymose
11-30-2003, 03:34 PM
I'm working with custom events, and I've run into a problem - when I dispatch the event (with dispatchEvent()) to the body of the page, it won't fire the function I assigned to the event handler, and instead I have to use event listeners. Is there any way to overcome this problem?

Any help is greatly appreciated. Thanks! :)

jkd
11-30-2003, 04:44 PM
If in an HTML attribute:

document.addEventListener("mycustomevent", function(event) {
eval(event.target.getAttribute("onmycustomevent"));
}, true);

Else if assigned via javascript:

document.addEventListener("mycustomevent", function(event) {
event.target.onmycustomevent();
}, true);

You might want to change the true to the false if you want to fire it on bubbling instead of on capturing, but whatever. The gist is there.

nolachrymose
11-30-2003, 05:58 PM
Thanks, jkd!


You might want to change the true to the false if you want to fire it on bubbling instead of on capturing, but whatever.

I didn't even realize, heh. *changed*



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum