Search the web
Sign In
New User? Sign Up
ydn-javascript · Yahoo! User Interface Library Group
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Show off your group to the world. Share a photo of your group with us.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Event Delegation   Message List  
Reply | Forward Message #5925 of 52114 |
HTML:
<div id="parent">
<div class="child">Test</div>
<div class="child">Test2</div>
</div>

Now I've got a click event handler that looks like:

YAHOO.util.Event.on('parent', 'click', clickDelegate);
function clickDelegate(e){
var origin = YAHOO.util.Event.getTarget(e, false);
if(YAHOO.util.Dom.hasClass(origin, 'child'))
alert(origin.innerHTML + ' was clicked.');
}

Now that works great...
My question is: How do I do that for the mouseover or mousemove event?
I can't seem to get that to work. here is what I'm doing now
(doesn't work):

YAHOO.util.Event.on('parent', 'mouseover', hoverDelegate);
function hoverDelegate(e){
var origin = YAHOO.util.Event.getTarget(e, false);
if(YAHOO.util.Dom.hasClass(origin, 'child'))
alert(origin.innerHTML + ' was hovered.');
}

my variable "origin" is always undefined. Hopefully you guys can see
what I'm trying to do. Any input would be appreciated.





Fri Oct 20, 2006 11:37 pm

prizeloop
Offline Offline
Send Email Send Email

Forward
Message #5925 of 52114 |
Expand Messages Author Sort by Date

HTML: <div id="parent"> <div class="child">Test</div> <div class="child">Test2</div> </div> Now I've got a click event handler that looks like: ...
prizeloop
Offline Send Email
Oct 20, 2006
11:42 pm

prizeloop, I wrote up a short example of this, as we need a better event delegation example anyway; you can check out that functional example here: ...
Eric Miraglia
ericmiraglia
Online Now Send Email
Oct 23, 2006
2:46 am

Thanks...I got my code working (I think it was some dumb coding error) but I got to thinking. Is the MouseMove event a good event to delegate? If my container...
prizeloop
Offline Send Email
Oct 23, 2006
10:10 pm

prizeloop, Your logic seems sound to me. Every time the event fires, your event handler will fire. Having that happen less often is a good thing, and it's a...
Eric Miraglia
ericmiraglia
Online Now Send Email
Oct 23, 2006
11:41 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help