YUI Treeview (override labelClick)

£可爱£侵袭症+ 提交于 2020-01-25 05:05:22

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!