如何使用jstree删除上下文菜单中的编辑选项?

时间:2015-03-16 12:24:27

标签: javascript jquery

我需要使用“jstree”jquery插件删除上下文菜单中的Edit选项。请告诉我们如何删除它。

我的代码是:

var contextualMenuSample = function(){

    $("#tree_3").jstree({
        "core" : {
            "themes" : {
                "responsive": false
            }, 
            // so that create works
            "check_callback" : true,
        },
        "types" : {
            "default" : {
                "icon" : "fa fa-folder icon-state-warning icon-lg"
            },
            "file" : {
                "icon" : "fa fa-file icon-state-warning icon-lg"
            }
        },
        "state" : { "key" : "demo2" },
        "plugins" : [ "contextmenu", "dnd", "state", "types" ],
        "contextmenu" : {
            "items" :{
            "Edit": false
            }
        }


    });

}

2 个答案:

答案 0 :(得分:0)

'contextmenu': {               
                'items' : function(node) {
                    var tmp = $.jstree.defaults.contextmenu.items();
                    tmp.ccp = false;
                }
 }

答案 1 :(得分:0)

这是我最简单的选择。所有主要代码都放在“ contextmenu.items”块中。

$('#c-list').jstree({
    "core": {
        "themes": {"responsive": false},
        "check_callback": true,
    },
    "types": {
        "default": {
            "icon": "fa fa-folder text-warning fa-lg"
        },
        "file": {
            "icon": "fa fa-file text-warning fa-lg"
        }
    },
    "contextmenu":{
        'items' : function(node) {
            var items = $.jstree.defaults.contextmenu.items();
            items.ccp = false;

            return items;
        }
    },
    "plugins": ["contextmenu", "dnd", "types", "search", "wholerow","checkbox"]
});