I would like to implement CTRL + Drag & Drop
in FullCalendar v5 using PURE JavaScript only.
I did my reseach on topic and found that this was discussed as a new feature UI request on FC github. There are few suggestions how to do that, even working ones.
You can use eventDrop to create this feature. jsEvent has a ctrlKey
on which you can test. Copy the event, received as a parameter, in a new variable.
revertFunc to make go back, and then apply renderEvent with the new variable created.
chris-verclytte posted on Apr 11, 2016 does nothing for me
If it can help, here is a little trick I use waiting for this new feature to be integrated.
In eventDrop callback
// If no alt key pressed we move the event, else we duplicate it
if (!jsEvent.altKey) {
// Handle drag'n'drop copy
} else {
// Handle drag'n'drop duplication
// Here I add the event to event source
_addEventToSelectedSource(event.start, event.end);
// "Disable" the default behavior using revertFunc to avoid event moving
revertFunc();
}
The only problem with this is that the copied event disappears during drag'n'drop due to https://github.com/fullcalendar/fullcalendar/blob/master/src/common/Grid.events.js#L273
I like the best solution by AllyMurray posted on Jul 13, 2018
For anyone that comes across this issue, I have created a solution that should give you a starting point to work from. It uses the same approach as external events and leaves the original event in place.
https://mcmap.net/q/1422871/-javascript-fullcalendar-copying-events
https://codepen.io/ally-murray/full/JBdaBV/
But I do not know how to implement this solution in pure javascript.
Could anyone help? I prefer the copy to work the way that CTRL press means copy so the original event stays in original position.
.draggable
bit with theDraggable
as described at fullcalendar.io/docs/external-dragging - it's used there for external events, but in principle it appears there's nothing stopping you making any element draggable using it. – Raama.draggable
withDraggable
or.Draggable
? Also I have no idea how to dymanically change FullCalendar options once it is set. What to replace$("#calendar").fullCalendar("option", "eventStartEditable", !isCopyable);
with. – ErfertDid you mean to reaplace .draggable with Draggable or .Draggable
... it's not just an find-and-replace task. The link I provided shows the syntax for creating a Draggable. – RaamaAlso I have no idea how to dymanically change FullCalendar options
...it's right there in the documentation. fullcalendar.io/docs/dynamic-options – Raama