search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Create event only by clicking (Calendar)

Asked by Arthur
1 month ago.

Hello everyone,

I'm trying to add an event by clicking on the calendar, without the option of the range (I want only by clicking).
I tried the onTimeRangeDoubleClicked but it's not working.

Answer posted by Dan Letecky [DayPilot]
1 month ago.

If you click a calendar cell, it will fire onTimeRangeSelect (and onTimeRangeSelected) event handler where you can create a new event. This works in both versions (Lite and Pro).

To make sure only a 30-minute event (for example) is created, you can use a calculated end instead of the provided args.end.

onTimeRangeSelected: args => {{
    start: args.start,
    end: args.start.addMinutes(30),
    // ...

In the Pro (paid) version, you can prevent a selection of multiple cells using onTimeRangeSelecting (since 2023.1.5536):

onTimeRangeSelecting: args => {
    if (args.anchor === args.start) {
        args.end = args.start.addMinutes(30);
    else {
        args.start = args.end.addMinutes(-30);

This will modify the visible selection and onTimeRangeSelected will receive the modified range.

See also:

The onTimeRangeDoubleClicked event only works on an existing selection and is only available in the Pro version.

New Reply
This reply is
or drop files here
Your name (optional):