jquery 上下文菜单中的显示事件不起作用
show event in jquery context menu not working
我想在显示之前显示和隐藏上下文菜单的一些选项。所以我在 documentation. But it is not working for me. fiddle
上使用 show
event
提及
show:function(){
alert(0)
}
嗯,所有选项都只是 javascript 对象。因此,在 $(document).ready 上,您可以修改选项集合以满足您的需要。这是我修改选项的示例:
$(function () {
var menuItems = {};
function somelogic() {
alert('hi');
return true;
}
if (somelogic()) {
menuItems = {
"edit": { name: "Edit", icon: "edit" },
"cut": { name: "Cut", icon: "cut" },
"copy": { name: "Copy This to the Clipboard Please", icon: "copy" },
"paste": { name: "Paste", icon: "paste" },
"delete": { name: "Delete", icon: "delete" },
"submenu": {
name: "Submenu",
items: {
"submenu_item1": {
// NOTE: this is the item that wraps in IE9 but not in Firefox
name: "Change Reporting Interval"
},
"submenu_item2": {
name: "Item 2"
}
}
},
"quit": { name: "Quit", icon: "quit" }
}
}
$.contextMenu({
selector: '.context-menu-one',
callback: function (key, options) {
var m = "clicked: " + key;
window.console && console.log(m) || alert(m);
},
items: menuItems
});
});
我想在显示之前显示和隐藏上下文菜单的一些选项。所以我在 documentation. But it is not working for me. fiddle
上使用show
event
提及
show:function(){
alert(0)
}
嗯,所有选项都只是 javascript 对象。因此,在 $(document).ready 上,您可以修改选项集合以满足您的需要。这是我修改选项的示例:
$(function () {
var menuItems = {};
function somelogic() {
alert('hi');
return true;
}
if (somelogic()) {
menuItems = {
"edit": { name: "Edit", icon: "edit" },
"cut": { name: "Cut", icon: "cut" },
"copy": { name: "Copy This to the Clipboard Please", icon: "copy" },
"paste": { name: "Paste", icon: "paste" },
"delete": { name: "Delete", icon: "delete" },
"submenu": {
name: "Submenu",
items: {
"submenu_item1": {
// NOTE: this is the item that wraps in IE9 but not in Firefox
name: "Change Reporting Interval"
},
"submenu_item2": {
name: "Item 2"
}
}
},
"quit": { name: "Quit", icon: "quit" }
}
}
$.contextMenu({
selector: '.context-menu-one',
callback: function (key, options) {
var m = "clicked: " + key;
window.console && console.log(m) || alert(m);
},
items: menuItems
});
});