【发布时间】:2017-03-09 09:51:26
【问题描述】:
我想通过 jQuery 显示有条件的 contextMenu 项目。
例如:
我的帐户中有汽车。我想根据条件显示选项。
如果汽车是我自己的,那么我应该可以看到所有菜单项。如果它与我共享,那么只有查看菜单对我可见。
if (type == 'vehicle') {
(function () {
var vehicle_id = node.data.vehicle_id;
var vehicle_status = '';
$.ajax({
url: baseUrl + '/check-vehicle-status/'+vehicle_id,
success: function(data) {
console.log(data);
if(data == 'shared'){
//what should I write here? to show only View option
}
}
});
items = {
"View": {
"label": "View Vehicle",
"action": function action() {
self.viewVehicle(vehicle_id);
}
},
"modify": {
"label": "Edit Vehicle",
"action": function action() {
self.editVehicle(vehicle_id);
}
},
"delete": {
"label": "Delete Vehicle",
"action": function action() {
dialogHandler.showDeleteVehicle(function () {
self.removeVehicle(vehicle_id);
});
}
},
【问题讨论】:
-
请分享你已经拥有的东西
-
我正在发送带有汽车 ID 的 ajax 调用,这给了我汽车是我自己的或与我共享的。如果与我共享汽车,我想添加此条件仅显示查看 oprion。其他明智的显示所有选项,如 EDIT、DELETE 等。
标签: javascript jquery contextmenu jstree