https://swisnl.github.io/jQuery-contextMenu I am using the context menu here
$.contextMenu({
selector: '.selectedItem',
// trigger: 'none',
callback: function (key, options) {
var m = "clicked: " + key;
// window.console && console.log(m) || alert(m);
},
items: {
edit: {name: "Edit", icon: "edit"},
cut: {name: "Cut", icon: "cut"},
}
});
When I right click on the selectedItem div, I want to fill the items:{} object, how can I do that? I don't want to fill it statically . When I click on the selectedItem class with the right click, I want to look at its properties and add a cut, edit delete feature.
To do what you require you can use the
buildproperty. You can use this to dynamically generate the options based on the element which triggered the context menu.Obviously, this is a contrived example using
dataattributes. You would most likely need to implement a lookup method to determine which options should be displayed for each context menu.