Using jQuery 1.2.x and jQuery UI 1.5.x, one of them was able to trigger the drag manually:
jQuery("#myDiv").mousedown(function(ev) {
target = jQuery(ev.target);
if (target.hasClass("drag-me")) {
target.draggable({
helper: "clone",
start: function()
{
console.log("drag start");
},
stop: function()
{
jQuery(this).draggable("destroy");
}
}).trigger("mousedown.draggable", [ev]);
} });
It applies to the following HTML:
<div id="myDiv">
<div class="drag-me"></div>
<div class="drag-me"></div>
<div class="drag-me"></div>
<div class="drag-me"></div>
<div class="drag-me"></div>
<div class="drag-me"></div>
<div class="drag-me"></div>
</div>
This was a convenient way to apply drag and drop to items inside a container in which its children dynamically changed. I like to call it a drag and drop delegation.
However, with the release of jQuery 1.3.x and jQuery 1.6+, the script add-in stopped working. Using jQuery 1.3.2 and jQuery UI 1.7.1 returns a "too much recursion" error.
How can I trigger a drag manually? Any suggestions?
source
share