jstree remove default elements from context menu

前端 未结 4 2104
独厮守ぢ
独厮守ぢ 2021-02-07 07:12

I have a problem with JsTree\'s contextmenu, how can I remove the default elements from the contextmenu like Create, Delete, Rename? I want to provide elements of my own, but th

4条回答
  •  花落未央
    2021-02-07 07:31

    If you like to modify labels of existing items or remove a few, a simple solution like below will work

    "contextmenu": {
       "items": function(node) {
               var defaultItems = $.jstree.defaults.contextmenu.items();
               defaultItems.create.label = "Ekle";
               delete defaultItems.ccp;
               return defaultItems;
            }
        }
    

    This will set "Create" items label as "Ekle" and remove cut copy paste from default items.

提交回复
热议问题