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

Use method on click (Calendar)

Asked by Arthur
1 year ago.

Hello,

When I'm clicking on an empty space, a modal appears. I want to know if it's possible to change it by using a method (already created) that will use my modal (already created in vue) with the date selected ?
It will be really helpful for me because it will directly communicate with my database.

Thanks in advance.

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

Yes - you should take a look at the onTimeRangeSelected event handler in your application.

By default, the calendar doesn't do anything when you select a time range (click a cell) so if you see a modal dialog there is already an onTimeRangeSelected handler that opens it. You can modify it as needed and open your own modal dialog instead.

Usually, it looks like this:

onTimeRangeSelected: async (args) => {
  const modal = await DayPilot.Modal.prompt("Create a new event:", "Event 1");
  const dp = args.control;
  dp.clearSelection();
  if (modal.canceled) { return; }
  dp.events.add({
    start: args.start,
    end: args.end,
    id: DayPilot.guid(),
    text: modal.result
  });
},

See also:
https://api.daypilot.org/daypilot-calendar-ontimerangeselected/

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.