问题
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.
回答1:
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.
回答2:
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_labelClick.
You can use "clickEvent" instead i suppose.
来源:https://stackoverflow.com/questions/1345981/yui-treeview-override-labelclick