Context menu from kanban icon

Hi,

I have an icon on my board like this:

{icon: "bars", click: function(e,id) { DoMenu(e,id); return false;}}

DoMenu looks like this:

            function DoMenu(e,id) {
                $$("itemMenu").attachTo(this);
                $$("itemMenu").show(e);
                webix.html.preventEvent(e);                    
            }

Then I handle the menu click event like this:

                $$("itemMenu").attachEvent("onItemClick",function(id){
                    alert(this.getItem(id).value);
                });                      

All is good, I click the card’s icon and the menu shows then when I click a menu item my event fires and I get a reference to the menu item that was clicked.
The bit that I’m missing is how to get the id of the card that showed the menu - I need to know which menu item was clicked + which card it was clicked on.

getContext works only if the context menu is attached as usual (.attachTo(obj) ) on a right click.

But if you need to attach the context menu to an icon, there’s another way: you can get the card ID via custom attribute (e.g. $context) and still you’ll be able to read it. Check the snippet:

http://webix.com/snippet/ecc7b090

But please note that the needed event here is onListIconClick, as the icon’s click occurs earlier and has no direct access to the required info.

That mechanism worked great thanks!
I didn’t know that ‘id’ could be set on the context menu item