| Page 1 of 1 | [ 4 posts ] |
|
If I have an EventTarget that happens to have children who use the same event prefix, is there an easy way to make sure that the events I'm subscribing to are fired from the 'self' target and not a child?
|
|
http://yuilibrary.com/yui/docs/base/
Usually if your class extends Y.Base, then the name of the class is prefixed to the event you are firing. I use Y.Views (which extend from Y.Base) and when I do something like... Code: myView.fire('myEvent') Then, the event name gets prepended with the name of the view class. So the 'myEvent' would actually be 'myView:myEvent' when I inspect the event facade for the event type. So you can discriminate based on the prefix. Note, that you need to fire the event from a class that extends from Base for this work as described, which after reading your original post does not apply to you, since you're just using EventTarget directly Or actually, even easier yet, either the currentTarget or target of the event facade (i forget which one it is) should always be the 'self' class you're referring to. So you can just check if the currentTarget or target is the 'self'. |
|
|
|
Thanks guys. Wow I can't believe I didn't think of that one. You guys rock!
|
| Page 1 of 1 | [ 4 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group