The makeDraggable() method activates an external element so it can be dragged to the JavaScript Scheduler component as an event. It supports dragging on touch devices as well.
This method is static. Call it using the full prefix, not on a DayPilot.Scheduler class instance.
Declaration
DayPilot.Scheduler.makeDraggable(options)Parameters
options.onDragStart- event handler fired on drag start; receivesargs.optionsandargs.preventDefault(); optionaloptions.onDrop- event handler fired on drop; receivesargs.options; optionaloptions.data- the source data object; available since 2021.2.4941. In prior versions, addid,text, anddurationdirectly tooptionsoptions.element(DOM element) - the element to activate for drag and dropoptions.remove(DOM element) - the element to remove on drop; if not specified,options.elementis usedoptions.keepElement(boolean) - set totrueif the original element should not be removed from the DOM on drop; optionaloptions.externalCssClass(string) - CSS class applied to the moving shadow when it is outside of the Scheduler; optionaloptions.externalCursor(string) - cursor used during external drag and drop (CSS format); available since 2024.4.6293options.externalHtml(string) - HTML added to the moving shadow when it is outside of the Scheduler; optionaloptions.tapAndHoldTimeout(number) - milliseconds to wait before moving is activated; optional; available since 2025.4.6741
The source data object (options.data) requires the following properties:
id(string | number) - event IDtext(string) - event textduration(number | DayPilot.Duration) - event duration; you can also supplystartandendinstead ofduration
Notes
All other properties of options.data are copied to the target object and are available in DayPilot.Scheduler.onEventMove as properties of args.e.data.
See External Drag and Drop for the full workflow.
Example
Assuming the page contains <div id="item" data-id="1" data-duration="60">Draggable item</div>:
const element = document.getElementById("item");
DayPilot.Scheduler.makeDraggable({
element,
data: {
id: element.getAttribute("data-id"),
text: element.innerText,
duration: element.getAttribute("data-duration")
}
});See Also
External Drag and Drop [doc.daypilot.org]
DayPilot.Scheduler.makeDraggableAsRow()
DayPilot.Scheduler.registerDropTarget()
Availability
Availability of this API item in DayPilot editions:
| Product | Lite | Pro |
|---|---|---|
| DayPilot for JavaScript |
DayPilot