Skip to content

onEventReceive

Hears an event that came into this calendar — made from an element of the page, or dragged from another calendar.

Type(change: EventChange) => void
Defaultnot set
Live update (update())Yes
Declared inpackages/dom/src/settings.ts

It receives the change, as onEventChange does: after is the event as it is here now, command the creation. Persist it; change.revert() takes it back — for an event from another calendar, on both sides: it goes back there. The calendar it left hears onEventLeave. Two calendars on one store (store) share the event: there it is a move, command is the move, and onEventLeave is not called.

import { createCalendar } from '@dzcalendar/dom';
createCalendar(element, {
timeZone: 'Europe/Paris',
editable: true,
droppable: true,
onEventReceive: async (change) => {
const res = await fetch('/api/events', { method: 'POST', body: JSON.stringify({ title: change.after?.title, start: change.after?.start.toString() }) });
if (!res.ok) change.revert();
},
});

In the frameworks it is an output: Angular’s (eventReceive), React’s onEventReceive, Vue’s @event-receive.