Reputation: 1463
for a menu checkItem, when user clicks at it, by default it will trigger checkchange; i am wondering how to, if a certain case is met, not change its check status after clicked, in other words, stop this event chain.
I tried following codes, but not work:
listeners: {
'click': function(item, evt) {
if(1) { //verify whether that certain case
evt.stopEvent(); //since click_event is triggered before setChecked()/checkChange, I thought this may stop its going further...
alert('case met!');
}
},
checkHandler: function(item, checked) {
//...
}
Upvotes: 2
Views: 3393
Reputation: 11486
You can listen to the beforecheckchange
event. Here it is in the docs.
As per the docs, just apply your conditional logic and if it doesn't pass, return false from the handler.
E.g.:
listeners: {
'beforecheckchange': function(item, checked) {
if(!1) { // or whatever your conditional logic is
return false;
}
},
}
Upvotes: 5