The onShow event handler fires before the context menu is displayed.
You can use it to modify the menu dynamically for the current source object before it becomes visible.
DayPilot.Menu.onShow(args)
args.div (HTML element) - menu DOM element (available since 2025.4.6749)args.menu (DayPilot.Menu) - context menu instanceargs.source (object) - source object (for example DayPilot.Event)args.preventDefault() - cancels menu activationUse this event to enable, disable, or update menu items based on args.source before the menu is shown. Call args.preventDefault() to cancel activation.
This example disables the first menu item if the source event has a readonly tag specified.
const sourceEvent = {
data: {
tags: {
readonly: true
}
}
};
const menu = new DayPilot.Menu({
items: [
{
text: "Edit...",
onClick: () => {
console.log("Showing details...");
}
}
],
onShow: (args) => {
const event = args.source;
args.menu.items[0].disabled = !!(event.data.tags && event.data.tags.readonly);
},
// ...
});
menu.show(sourceEvent);
Availability of this API item in DayPilot editions:
| Lite | Pro | |
|---|---|---|
| DayPilot for JavaScript |
Lite args missing: div