ContextMenu action on a event. Event ID?

Hi,

I added a context menu to my scheduler events:

[code]var menu = new dhtmlXMenuObject();
menu.renderAsContextMenu();
menu.loadXMLString(’’);

scheduler.attachEvent(“onContextMenu”, function(event_id, native_event_object) {
if (event_id) {
var posx = 0;
var posy = 0;
if (native_event_object.pageX || native_event_object.pageY) {
posx = native_event_object.pageX;
posy = native_event_object.pageY;
} else if (native_event_object.clientX || native_event_object.clientY) {
posx = native_event_object.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
posy = native_event_object.clientY + document.body.scrollTop + document.documentElement.scrollTop;
}
menu.showContextMenu(posx, posy);
return false; // prevent default action and propagation
}
return true;
});[/code]

And I defined some accions to the menu items with:

menu.attachEvent("onClick", function(id) { var menuname = menu.getItemText(id); alert(id); alert(menuname); });

How can I access to the clicked event ID from here?

Thx

Hi,
you have to save event id to some variable in onContextMenu, so it could be accessed later.

I thought I could pass the event id as a parameter to the menu. Ok, I made a global variable inside a scoping function where I define the menu.attachEvent and scheduler.attachEvent, so they can share the same variable.

(function() { var event_id = null; (...) menu.attachEvent("onClick", function(id) { alert(event_id); (...) }); scheduler.attachEvent("onContextMenu", function(event_id_loc, native_event_object) { event_id = event_id_loc; (...) } })();