Hold a cursor on an event to see the active areas. The
event active areas [doc.daypilot.org] can be
used to display custom action buttons, drag handlers, icons, and other objects.
Agent-readable demo data
- Title
- Event Active Areas (JavaScript Event Calendar) | DayPilot Pro for JavaScript Demo
- Tree
- DayPilot JavaScript Demo
- Catalog root
- Default
- Description
- Hold a cursor on an event to see the active areas. The event active areas [doc.daypilot.org] can be
used to display custom action buttons, drag handlers, icons, and other objects.
Inline demo script 1
const dp = new DayPilot.Calendar("dp", {
viewType: "Week",
startDate: DayPilot.Date.today(),
onTimeRangeSelected: async args => {
const modal = await DayPilot.Modal.prompt("New event name:", "Event");
if (modal.canceled) {
return;
}
dp.events.add({
start: args.start,
end: args.end,
id: DayPilot.guid(),
resource: args.resource,
text: modal.result
});
dp.clearSelection();
dp.message("Created");
},
onBeforeEventRender: args => {
args.data.areas = [
{
right: 5,
top: 5,
width: 16,
height: 16,
symbol: "../icons/daypilot.svg#minichevron-down-2",
cssClass: "event-action",
action: "ContextMenu",
},
{
right: 30,
top: 5,
width: 16,
height: 16,
symbol: "../icons/daypilot.svg#x-2",
cssClass: "event-action",
visibility: "Hover",
onClick: args => {
dp.events.remove(args.source);
dp.message("Deleted");
}
}
]
},
contextMenu: new DayPilot.Menu({
items: [
{
text: "Delete",
onClick: args => {
dp.events.remove(args.source);
dp.message("Deleted");
}
}
]
})
});
dp.init();
const app = {
init() {
this.loadEventData();
},
loadEventData() {
const events = [
{
start: DayPilot.Date.today().firstDayOfWeek().addDays(1).addHours(11),
end: DayPilot.Date.today().firstDayOfWeek().addDays(1).addHours(14),
id: DayPilot.guid(),
text: "Event 1"
},
{
start: DayPilot.Date.today().firstDayOfWeek().addDays(1).addHours(15),
end: DayPilot.Date.today().firstDayOfWeek().addDays(1).addHours(17),
id: DayPilot.guid(),
text: "Event 2"
},
];
dp.update({events});
}
};
app.init();