The makeDraggable() method activates an external item so it can be dragged to the Calendar as a new event. It supports dragging on touch devices as well.
This method is static. Call it using the full DayPilot.Calendar.makeDraggable() prefix, not on a DayPilot.Calendar instance.
Declaration
DayPilot.Calendar.makeDraggable(options);Parameters
options.element(DOM element) - DOM node to activate for external drag and dropoptions.data(object) - event data; available since 2021.3.5096options.remove(DOM element) - DOM node removed on drop; if not specified,options.elementis usedoptions.keepElement(boolean) - set totrueif the original element should not be removed from the DOM on dropoptions.externalCssClass(string) - CSS class applied to the moving shadow when it is outside of the Calendaroptions.externalCursor(string) - cursor used during external drag and drop (CSS format); available since 2020.2.4381options.externalHtml(string) - HTML added to the moving shadow when it is outside of the Calendaroptions.onDragStart- event handler fired on drag start; receivesargs.optionsandargs.preventDefault(); optional; available since 2024.4.6293options.onDrop- event handler fired on drop; receivesargs.options; optional; available since 2024.4.6293
The options.data object can define the following properties:
id(string) - event IDtext(string) - event textduration(number | DayPilot.Duration) - event duration; a numeric value specifies the duration in seconds
Any additional properties of the options.data object are copied to the Calendar event data object on drop.
Notes
If options.remove is not specified, options.element is used and removed after a successful drop unless options.keepElement is set to true.
Use externalCssClass, externalHtml, and externalCursor to customize the moving shadow while the dragged item is outside of the Calendar.
Example
<div id="item" data-id="1" data-duration="60">Draggable item</div>
<script>
const e = document.getElementById("item");
const item = {
element: e,
data: {
id: e.dataset.id,
text: e.innerText,
duration: e.dataset.duration
}
};
DayPilot.Calendar.makeDraggable(item);
</script>See Also
External Drag and Drop [doc.daypilot.org]
Availability
Availability of this API item in DayPilot editions:
| Product | Lite | Pro |
|---|---|---|
| DayPilot for JavaScript |
DayPilot