Calling function on click of top level menu item.

I’ve seen how to call a function based on clicking an item within a menu, but how do you call a function on click (or on Touch) of the main top level menu items e.g. the “FILE” menu.

Thanks in advance!

You may set onTouch event handler:

menu.attachEvent(“onTouch”, function(id){

});

I tried that and it’s a bit unreliable - if you move your mouse across the top level menu items the function does not always get called. You have to move your mouse away from the menu area altogether and then back to a different menu item to get the function to fire.

Is there a way to correct this?

Thanks again.

we have reproduce the problem and will try to fix it. We’ll send the fix when it’s ready.

Sorry for the misleading information in my previous answers. You may use onShow and onHide events. onClick will be called if an item has no child items:

dhtmlxMenu/samples/05_events/01_events_single.html