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

问题描述 投票:0回答:1

我试图在上下文菜单显示和隐藏时调用一些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,语法显示正确。请帮助解决我做错的事情。

javascript jquery contextmenu jstree
1个回答
1
投票

正如 API 所说 - 事件在文档上触发,因此替换:

$("#myTree").bind
$(document).bind

© www.soinside.com 2019 - 2024. All rights reserved.