jstree remove default elements from context menu

前端 未结 4 2060
独厮守ぢ
独厮守ぢ 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:20

    I had this issue a couple of days ago but haven't yet decided if this is a bug or a feature. It may be related to the order in which the plugins are loaded.

    What worked for me was returning the items from a function:

    "contextmenu" : {
        "items" : function ($node) {
            return {
                "IsimVer" : {
                    "label" : "İsim Değiştir",
                    "action" : function (obj) { this.rename(obj); }
                },
                "Ekle" : {
                    "label" : "Ekle",
                    "action" : function (obj) { this.create(obj); }
                },
                "Sil" : {
                    "label" : "Sil",
                    "action" : function (obj) { this.remove(obj); }
                }
            };
        }
    }
    

    After some searching it seems that the default behaviour is for your menu items to extend the defaults, so this is a feature. Unfortunately the documentation currently lacks the detail on this point.

提交回复
热议问题