Copy-pasting an event - display problem

Hello,
I am trying to copy and paste an event, using key_nav.
It is working fine, I managed to save events in my DB. However, when pasting an event, the starting date shown on the scheduler is always “00:00”.
When I open the LightBox for this event, correct values are displayed.
If I refresh the scheduler, the starting date shown on the scheduler is correct.
I attached a screenshot; the right event is a copy of the left one. But as you can see, dates aren’t the same.

Is there a way to get the correct starting date displayed ?

Thank you very much !

Khwaja

Hello,

By default the start_date for new event is set according to cursor position when event is created. There is no hour scale in the month view, so the start time is set automatically to 00:00.

To solve the issue, you can save start/end time of copied event by “onClick” and set these values to new event by “onEventAdded”. Please, check the demo:
docs.dhtmlx.com/scheduler/snippet/3d08bc55

Hello Polina,
Thank you for your reply !

I managed to modify a bit your code to implement it in my project, and it seems to work nicely now.

However, I just have a question in this event :

scheduler.attachEvent("onEventAdded", function(id,ev){ if(key && scheduler.getState().mode=='month'){ ev.start_date.setHours(start_hour); ev.start_date.setMinutes(start_min); ev.end_date.setHours(end_hour); ev.end_date.setMinutes(end_min); scheduler.updateEvent(id); key = 0; } });

Why do you need this condition ? if(key && scheduler.getState().mode=='month'){

Hello,

scheduler.getState().mode==‘month’

This condition for check the view mode, while you copy an event.

key

In this case you can create only 1 copy of event with the same start_ and end_ dates. If you need to create more - remove it and use only:
if(scheduler.getState().mode==‘month’){ … }

Hello Polina,
Thank you for your help ! Everything is working now.