Checkbox change other option disabled value
Hi, im try to change the disabled value but i dont know how.
I have the next piece of code:
$(function(){
$.contextMenu({
selector: '.context-menu-one',
callback: function(key, options) {
var m = "clicked: " + key;
window.console && console.log(m) || alert(m);
},
items: {
"changeCB": {
name: "ChangeCheckBox",
type: 'checkbox',
selected: true,
events: {
click: function(e) {
var $input = $(this);
var $item = $input.closest('li');
var data = $item.data();
if ($input.prop('checked')){
//WHEN CHECKED -> "DoOther" enable
}else{
//WHEN UNCHECKED -> "DoOther" disable
}
}
}
},
"DoOther": {
name: "Do Other function",
disabled: function(key, opt) {
// this references the trigger element
return !this.data('cutDisabled');
}
}
}
});
});
Edit, put the code in a code block
It would help if you can make a jsfiddle with this issue so i can reproduce is easily :)
I Have the same issue. Tested like done here, and i as well tried to put "this.data('cutDisabled', !this.data('cutDisabled'));" from the example. It works on callback but not on radio or checkbox events. Error is "basScripts.js:480 Uncaught TypeError: this.data is not a function" Please help! Here is another fiddle: https://jsfiddle.net/egxv8r7z/ I could create another one for "change" event and radio buttons, but the error is the same so...
It seems this is not the same in the context of that click event. In the relevant demo it uses the callback. I think this in your fiddle refers to the clicked element, so that is not the same at all.
So perhaps in your code check out whats in the e variable you get from function(e). You should be able to find the menu element in there which you can use. (the function should be function(opt) i think, which is the same argument as passed in disabled: function(key, opt).