AndyLurch AndyLurch - 3 months ago 17
HTML Question

How to disable a single menu item?

Apparently I have another Webix question.

I'm trying to disable a single menu item, but the

onItemClick
action for submenu is still works. Here's my code:

webix.ui({
view:"menu",
id:'menu',
data:[
{
id:'root',
value:'Available actions',
config:{
on: {
onItemClick: function(id){ webix.message(id) }
}
},
submenu:[
{ id:'1', value:'Open...' }
]
}
]
});

$$('menu').disableItem('1');


Full sample: http://webix.com/snippet/9128f7b0

Where I was wrong and is there any way to disable menu item?

Answer

Change onItemClick to onMenuItemClick.

Example: http://webix.com/snippet/8cba874c

From Webix docs:

Both methods can be used in either of menu inner events, for instance, click events: onMenuItemClick - fires on clicking all menu items regardless of hierarchy level. Ignores disabled items; onItemClick - standard event that fires on clicking any item of the same hierarchy level. Fires for disabled item as well.