Skip to content

onDateClick

Hears a click on empty time in a time grid, or on a day — and Enter on the keyboard cursor.

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

It receives { allDay, date, instant?, resourceId? }:

  • in a time grid, allDay: false, the day and the start of the slot clicked (on snapMinutes: a click at 10:37 says 10:30, as the context menu does);
  • on a day cell or the all-day row, allDay: true and the date;
  • in a resource view, the column’s resourceId.

Space, or Enter on an empty slot, at the keyboard’s cursor is a date click too — and, in a selectable calendar, also selects that slot (Enter on a day holding events goes into its events; while Shift+arrows select, Enter gives the selection instead; on a free slot with onSlotClick, that one is called). A mouse click never selects; a drag does, and so does a tap on a touch screen.

import { createCalendar } from '@dzcalendar/dom';
createCalendar(element, {
timeZone: 'Europe/Paris',
onDateClick: (click) => console.log(click.allDay ? `day ${click.date}` : `at ${click.instant.toString()}`),
});

In the frameworks it is an output: Angular’s (dateClick), React’s onDateClick, Vue’s @date-click.