Alex Rivera | Logout

Jquery ui, call start drag manually

Asked 2009-04-08T14:56:12.127
12

In Jquery UI I can configure an element as draggable by invoking

$("#drag").draggable();

But is there a way to start and stop the drag functions manually from another function? Ie

someOtherFunction = function() {
  $("#drag").startdrag();
}
yetAnotherFunction = function() {
  $("#drag").stopdrag();
}
Edit
Report

1 Answer

1

I didnt find a way to trigger dragging manually, but I have found a workaround for my similar situation.

I had this situation with two overlapping images (see image below), both partially transparent. In draggable's start(event) I wanted to check if it hits transparent pixels. If so, I looked under it for another element to see if that one was hit. And if it was, I wanted to initiate its dragging.

enter image description here

Solution? I reorder images on mousemove, and draggable is then triggered for that topmost image.

For pixel-precise element selection, see my another answer in: registering clicks on an element that is under another element

answered 2012-11-17T01:36:31.270

Your Answer