gpt4 book ai didi

javascript - 尝试从 jquery-contextmenu 菜单中动态删除 "sep1"项。我该如何处理它?

转载 作者:行者123 更新时间:2023-12-03 05:26:52 26 4
gpt4 key购买 nike

我正在使用jquery-contextmenu对于我的项目。我创建了以下菜单,其中有几个需要动态隐藏的分隔符(sep1、sep2...等)。我该如何处理它?问题是当我动态隐藏某些项目时,分隔符仍然可见。

$.contextMenu({
selector: '#ItemSelector',
callback: function (key, options) {
var m = "clicked: " + key;
window.console && console.log(m) || alert(m);

//handle event once right click is pressed on any option.

},
events: {
show: function (options) {
//some code
}
},
items: {
"menu_context_selection": {
name: "Start/Stop Selection",
icon: "fa-check-square-o",
visible: function (key, opt) {
return !true;
}
},
"menu_context_open": {
name: "Open",
icon: "fa-folder-open-o",
visible: function (key, opt) {
return true;
}

},
"sep1": "---------",
"menu_context_rename": {
name: "Rename",
icon: "fa-keyboard-o",
visible: function (key, opt) {
return !true;
}
},
"menu_context_delete": {
name: "Delete",
icon: "fa-recycle",
visible: function (key, opt) {
return !true;
}
},
"sep2": "---------",
"menu_context_newfolder": {
name: "New Folder",
icon: "fa-folder-o",
visible: function (key, opt) {
return !true;
}
},
"sep3": "---------",
"menu_context_copy": {
name: "Copy",
icon: "fa-files-o",
visible: function (key, opt) {
return !true;
}
}
}
});

最佳答案

只需返回一个可见属性设置为 false 的对象

"sep1": true ? "---------" : {visible: false}

关于javascript - 尝试从 jquery-contextmenu 菜单中动态删除 "sep1"项。我该如何处理它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41108588/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com