How to subscribe for child event only in YUI3 widget-parent/child?

Go To StackoverFlow.com

0

Good day!

I'm trying to build hierarchical widget with YUI3 Widget-parent and widget-child and currently studying Hierarchical ListBox Widget.

I want to subscribe only to click event of the particular child that was clicked. Continuing usage example from the above page, I'm doing:

listbox.on("listbox:click", function(e) {...});

Now when I click on the "Item Three - Two" entry in the list, this event gets fired for "Item Three - Two", "Item Three" and root widgets. Inside that event handler, I've found no way to determine whether e.target is the original widget I've clicked on or one if its parents.

So my questions are:

  1. How do I discover that I'm in event handler of the original widgetthat was clicked?
  2. Is it possible to make clicked widget be the only one that fires the event?

Thank you.

2012-04-05 23:23
by Zaar Hai


1

Here's an example fiddle.

If you're just wanting to get the leaf node as e.target use:

listbox.on('option:click', function (e) {...

Subscribing to the listbox:click actually doesn't pick up the leaf node in my example, but it picks up the click for the two parent listbox ancestor widgets.

2012-04-09 15:20
by mjhm
The problem is actually a big deeper. I've written about it in more depth here: link and here: linkZaar Hai 2012-05-20 14:42
Ads