Issue with dhtmlxMenu 2. (pro) & showContextMenu() onClick

Hi everyone,

I’m trying to display a context menu when left clicking on div I created, but the context menu isn’t showing up.

<div id="test" onclick="menu.showContextMenu(10, 10);">Menu here!</div>

<script type="text/javascript">
    var menu;

    menu = createContextMenu();
     
    function createContextMenu() { 
        var newMenu = new dhtmlXMenuObject(null, "dhx_skyblue");
        [...]

        return newMenu;
    }
</script>

I can get it to come up just fine if I call menu.showContextMenu(…) directly from the JavaScript console, but not from any mouse event. I’ve tried jQuery click(), mouseup(), mousedown() and the example above is using a regular onclick handler. Nothing seems to work. Any ideas?

Thanks!

Apparently I can’t edit my original post, but looks like I hit the limit on the topic. I’m using 2.6 if that helps any.

Hi,

you need to disable hiding menu on click:

menu.contextAutoHide = false;

To disable opening menu on right click:

menu.contextAutoShow = false;

Awesome, works great! Thanks Alexandra.