如何获取jquery上下文菜单插件的name属性。我能够获得回拨的关键但无法得到名字。我的代码如下。 在我的代码中,“possibleStatuesArray”的值将作为“更改电路状态”下的子菜单。
possibleStatuesArray=['RFS','IS','OOS'];
function RightClickMenus(selectorName, possibleStatuesArray) {
$.contextMenu({
selector: selectorName,
items: {
"fold1": {
"name": "Change circuit status",
"items": {
"fold1-key1": {"name": possibleStatuesArray[0]},
"fold1-key2": {"name": possibleStatuesArray[1]},
"fold1-key3": {"name": possibleStatuesArray[2]}
}
},
},
callback: function(key, options) {
alert("options**: " + options.key.name);
// Do stuff when something gets clicked on
console.log("options::::: " + options);
},
});
}
答案 0 :(得分:0)
更新:
http://jsfiddle.net/hgxc67Lm/3/
callback: function (key, options) {
var name=$('.context-menu-list .hover:last').text();
alert(name);
},