The onEventMove event handler fires when drag and drop event moving in the JavaScript Calendar is completed, before the default action is performed.
Declaration
DayPilot.Calendar.onEventMove(args)Parameters
args.e(DayPilot.Event) - calendar event being movedargs.newStart(DayPilot.Date) - new event startargs.newEnd(DayPilot.Date) - new event endargs.newResource(string | number) - ID of the new resource in resource calendar modeargs.external(boolean) - indicates that the event was dragged from an external sourceargs.ctrl(boolean) - state of the Ctrl keyargs.shift(boolean) - state of the Shift keyargs.preventDefault()- cancels the default action configured by DayPilot.Calendar.eventMoveHandling
Notes
The default action is specified using DayPilot.Calendar.eventMoveHandling and is enabled by default. Call args.preventDefault() when you need to cancel the move before it is applied.
You can check custom rules for the target position.
You can ask users for confirmation before actually moving the calendar event.
See also DayPilot.Calendar.onEventMoved, which fires after the default action. This event handler is also available in the open-source calendar component.
In api=1 mode, this event is only called if eventMoveHandling is set to "JavaScript". This API mode is used in versions with an integrated server-side part (ASP.NET WebForms, ASP.NET MVC, Java). The legacy signature is onEventMove(e, newStart, newEnd, newResource, external, ctrl, shift).
Legacy parameters:
e(DayPilot.Event) - reference to the moved itemnewStart(DayPilot.Date) - new event startnewEnd(DayPilot.Date) - new event endnewResource(string) - ID of the new resourceexternal(boolean) -trueif this was a move from an external sourcectrl(boolean) -trueif the Ctrl key was pressed on dropshift(boolean) -trueif the Shift key was pressed on drop
Examples
JavaScript
const calendar = new DayPilot.Calendar("dp", {
onEventMove: (args) => {
if (args.external) {
args.preventDefault();
console.log("External drop forbidden");
}
},
// ...
});
calendar.init();Angular
<daypilot-calendar [config]="config"></daypilot-calendar>config: DayPilot.CalendarConfig = {
onEventMove: (args) => {
if (args.external) {
args.preventDefault();
console.log("External drop forbidden");
}
},
// ...
};React
<DayPilotCalendar
onEventMove={onEventMove}
{/* ... */}
/>const onEventMove = (args) => {
if (args.external) {
args.preventDefault();
console.log("External drop forbidden");
}
};Vue
<DayPilotCalendar
@eventMove="onEventMove"
<!-- ... -->
/>const onEventMove = (args) => {
if (args.external) {
args.preventDefault();
console.log("External drop forbidden");
}
};See Also
Event Moving [doc.daypilot.org]
External Drag and Drop [doc.daypilot.org]
DayPilot.Calendar.eventMoveHandling
DayPilot.Calendar.onEventMoved
Availability
Availability of this API item in DayPilot editions:
| Product | Lite | Pro |
|---|---|---|
| DayPilot for JavaScript |
Lite args missing: areaData, async, external, hideShadow, loaded
DayPilot