views:

597

answers:

2

I am using dynamical loading in treeview, however I want it to load children nodes when click the plus icon instead of clicking label, I tried to override lableClick event and preventDefault event, but it didn't work, yui still load the children node when I clicked label

tree.subscribe("labelClick", function(e) {
    YAHOO.util.Event.preventDefault(e);
});

Any ideas to solve this problem? Thanks in advance.

A: 

If you will check YUI API you fill find out that there are no labelClick event on TreeView widget http://developer.yahoo.com/yui/docs/YAHOO.widget.TreeView.html#event%5FlabelClick.

You can use "clickEvent" instead i suppose.

Eldar Djafarov
Hi, Djko, YUI Treeview does have labelClick event, see http://developer.yahoo.com/yui/treeview/, search 'labelClick'
Stackless
"Event labelClick is deprecated, though kept for compatibility. Use clickEvent instead." from your link
Eldar Djafarov
A: 

The first parameter passed to your function is not the event, it's the node that was clicked, that's why your preventDefault isn't working.

Change the first parameter's name to node and the preventDefault line to "YAHOO.util.Event.preventDefault(node.event);"

I believe you should also return false.

camomileCase
Good point, Thanks!
Stackless