Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-30-2003, 02:34 PM   PM User | #1
nolachrymose
Regular Coder

 
Join Date: Jun 2002
Posts: 338
Thanks: 0
Thanked 0 Times in 0 Posts
nolachrymose is an unknown quantity at this point
Custom Event Attributes

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!
nolachrymose is offline   Reply With Quote
Old 11-30-2003, 03:44 PM   PM User | #2
jkd
Senior Coder

 
jkd's Avatar
 
Join Date: May 2002
Location: metro DC
Posts: 3,163
Thanks: 1
Thanked 18 Times in 18 Posts
jkd will become famous soon enough
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.
__________________
jasonkarldavis.com

Last edited by jkd; 11-30-2003 at 03:48 PM..
jkd is offline   Reply With Quote
Old 11-30-2003, 04:58 PM   PM User | #3
nolachrymose
Regular Coder

 
Join Date: Jun 2002
Posts: 338
Thanks: 0
Thanked 0 Times in 0 Posts
nolachrymose is an unknown quantity at this point
Thanks, jkd!

Quote:
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*
nolachrymose is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:41 PM.


Advertisement
Log in to turn off these ads.