jstree从上下文菜单中删除默认元素 [英] jstree remove default elements from context menu

查看:142
本文介绍了jstree从上下文菜单中删除默认元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JsTree的contextmenu有问题,我如何从Create菜单,Delete菜单,Rename菜单等上下文菜单中删除默认的元素?我想提供我自己的元素,但默认元素仍然处于上下文菜单中。

 contextmenu:{
items:{
IsimVer:{
label:İsimDeğ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); }
}
}


解决方案

前几天我有这个问题,但还没有决定这是一个错误还是一个功能。这可能与插件的加载顺序有关。



我的工作是从函数返回项目:

 contextmenu:{
items:function($ node){
return {
IsimVer:{
label:İsimDeğ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); }
}
};




$ b经过一番搜索之后,似乎默认行为是用于菜单项扩展默认值,所以这是一个特征。不幸的是,文档目前缺乏这方面的细节。


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 the default elements are still at the contextmenu.

    "contextmenu" : {
                    "items" : {
                        "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); }
                        }
}

解决方案

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.

这篇关于jstree从上下文菜单中删除默认元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆