显示和隐藏上下文菜单时的 Jstree 调用事件

Jstree call event when context menu is shown and hidden

本文关键字:Jstree 调用 事件 菜单 隐藏 上下文 显示      更新时间:2023-09-26

当上下文菜单显示并被隐藏时,我正在尝试调用一些javascript代码(当我右键单击并出现上下文菜单时显示;隐藏是当我单击上下文菜单外时,它从页面中消失)。我尝试了以下方法,但事件从未被触发。

// Create instance for tree
$(function () {
    $('#myTree').jstree({
        "core": {
            "themes": {
                'name': 'default',
                "variant": "small",
                "icons": false
            }
        },
        "contextmenu": {
            "items": getMenu(),
            "select_node": false
        }
        ,"plugins": ["contextmenu"]
    });
});
// when context menu is shown
$("#myTree").bind('context_show.vakata', function (reference, element, position) {
    // code to do...
});
// when context menu is hidden
$("#myTree").bind('context_hide.vakata', function (reference, element, position) {
    // code to do...
});

根据 API 显示语法正确。请帮助我做错了什么。

正如 API 所说 - 事件在文档上触发,因此请替换: $("#myTree").bind $(document).bind

此致敬意伊凡