简体   繁体   English

单击fancytree.js的第二级时如何警告消息

[英]how to alert a message when click on the second level on fancytree.js

I'm using fancytree.js i want to alert a message when i clic on a node. 我正在使用fancytree.js,当我选择节点时,我想提醒消息。 but not all nodes. 但并非所有节点。 Just when clicking on the nodes in the 2nd level. 仅在第二级上单击节点时。 Example

  <ul> <li>1</li> <ul> <li>1.1</li> <li>1.2</li> </ul> <li>2</li> <ul> <li>1.1</li> <li>1.2</li> </ul> <li>3</li> </ul> 

i want just alert when on clicking on 1.1 and 1.2 or 2.1 and 2.2 我只想在单击1.1和1.2或2.1和2.2时发出警报

$(document) . ready(function () {
    var data = '{{ path('gouvernorat_map') }}';
    $("#filter_switches") . fancytree({
        source: {
            url:data
        },
        icon: false,
        keyboard: true,
        quicksearch: false,
        tooltip: false,
        click: function (event, data) {
            alert(data . node + '---' + data . node . key + '---' + data . node . title + '---');
        }
    });
});

this alert when i click in any level. 当我单击任何级别时,此警报。 so how can i did it? 那我该怎么办呢?

you can ask the level from any node by using data.node.getLevel() . 您可以使用data.node.getLevel()从任何节点询问级别。 If you put this into an if-statement, you can filter by level. 如果将其放入if语句中,则可以按级别进行过滤。

For more information, see the documentation of fancytree 有关更多信息,请参见fancytree的文档。

Good luck 祝好运

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM