I’ve set up a context menu. I’m storing the selected EventID when the menu opens, and then clearing the value when execution has completed.
One of the options pops up confirm dialog ‘Do you want to delete this meeting?’. However, because the dhtmlx version of this doesn’t pause code execution, the value I have stored has been cleared before the callback has been actioned.
Is there a way for me to pass a value into the callback of a confirm message? (Other than the true/false result)?
You could store this id in some place available for confirm popup callback. E.g. through closure or maybe set this id as property for menu (menu.scheduler_event_id = EventID).
For example:
var ev_id = null;
menu.attachEvent("onClick", function(id, zoneId, cas){
if(id == "delete" && ev_id)
dhtmlx.confirm({
title: "Close",
type:"confirm-warning",
text: "Are you sure you want to do it?",
callback: function(res) {if(res) scheduler.deleteEvent(ev_id);}
});
});
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);
ev_id = event_id;
return false; // prevent default action and propagation
}
return true;
});
Get a guaranteed answer from DHTMLX technical support team
under the most suitable support plan