本文介绍了YUI Treeview(覆盖labelClick)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在树视图中使用动态加载,但是我希望它在加载子节点时单击加号而不是单击标签,我试图覆盖lableClick事件和preventDefault事件,但它不起作用,yui仍然加载点击标签的孩子节点

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

任何想法来解决这个问题?感谢提前。

解决方案

传递给您的函数的第一个参数不是事件,它是点击的节点,这就是为什么您的preventDefault不工作。



将第一个参数的名称更改为节点,将preventDefault行更改为YAHOO.util.Event.preventDefault(node.event);



我相信你也应该返回false。


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.

解决方案

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.

这篇关于YUI Treeview(覆盖labelClick)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 12:43