My goal is to create a unique functionality using the HTML5 Drag And Drop API
and jQuery. I want to trigger a dragover
event, then have a jQuery draggable
object follow the mouse until the dragend
event occurs.
The reason for this is that I am working on an application that relies on the jQuery.ui draggable
feature for a specific plugin (FullCalendar Scheduler
v3). I aim to enhance the application by allowing users to drag and drop items from one browser window to another within the mentioned plugin.
Since the plugin does not support the native HTML5 Drag and Drop API
and jQuery.ui draggable
cannot handle cross-window dragging, my solution involves combining these two plugins.
My proposed approach is to utilize the HTML5 Drag and Drop API
to create a new draggable element in the target browser window when a dragged item enters a dropzone
. By simulating a mousedown
event on the new draggable element, it will track the cursor's movement. Upon triggering the dragend
event, I plan to simulate a mouseup
event on the draggable element, enabling the scheduler plugin to function accordingly.
To test this method initially with a single browser window, I attempted to implement the first part of my solution: creating a jQuery.ui draggable
element and initiating its movement via a simulated mousedown
event during a dragover
event. However, I encountered difficulties achieving the desired behavior.
I provided a fiddle showcasing my attempts thus far (full code not included here): JSFiddle
Unfortunately, I encountered a type.indexOf is not a function
error while testing both options in the Fiddle.
I sought assistance on a related question where a solution was proposed for starting the drag operation with a click
event, but other event types did not yield the same result. It seems a mousedown.draggable
event can only be simulated from a MouseEvent
, which the dragend
event is not.
In essence, I require guidance to successfully implement the intended functionality, especially for the initial phase of my proposed solution!