JSTree select_node event firing twice

淺唱寂寞╮ 提交于 2019-12-06 04:32:04

When you select the root node, the code will only fire once. When you select a child node, the child node is still a part of the root node. So the code will fire once for the child node, and once for the root node.

If you were to have 7 levels deep of child nodes, the event would fire seven times.

An example of how to handle it inside the event handler is to check that the target the event is firing on is the current target that was selected or clicked:

this._tree = this.$('.js-tree');

if(this._tree.get_node(evt.target) == this._tree.get_node(evt.currentTarget){
    //Do event logic
} else {
    //Do nothing
    return;
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!