YUI2.8: How to target element with handler applied only
I'm having some probs with event propagation, I understand the concept, but I don't understand how to squash the default YUI behaviour.
I have this开发者_StackOverflow markup: [divElement id="container"][imageElement ... /][/divElement]
I have added a click event to the container element like so: ye.on(yd.get('container'), 'click', function(el){ // do stuff });
Ok, so I click the img, and ye.getTarget(); tells me the target was the img, which it is because I clicked it - but I assigned the handler to the container, not the img. In my situation it is important that I manipulate only the container, and not the img.
How can I ensure that when I click either the container or the img, that the target of my click event is only the container?
cheers, d
Time to make myself look like a dork:
http://yuilibrary.com/forum/viewtopic.php?f=14&t=3846&p=13336#p13336
All I needed was to access the default context for the event, by using the 'this' keyword. That's it, that was all.
精彩评论