DayPilot.Calendar.clearSelection

The clearSelection() method clears the current time range selection in the JavaScript Calendar component.

Declaration

DayPilot.Calendar.clearSelection()

Example

The typical usage is to clear the selection in the onTimeRangeSelected event handler (the selection stays visible by default):

const dp = new DayPilot.Calendar("dp", {
  onTimeRangeSelected: async (args) => {
    const modal = DayPilot.Modal.prompt("New event name:", "Event");
    dp.clearSelection();
    if (name.canceled) {
      return;
    }
    dp.events.add({
        start: args.start,
        end: args.end,
        id: DayPilot.guid(),
        text: modal.result
    });
  },
  // ...
});
dp.init();