Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery ui draggable, drag parent div

As the title says i want to drag div parent, let's say i have this structure

<div class="parent">
  <divc class="draggable"></div>
</div>

$(".draggable").draggable();

So how can i drag .parent instead of .draggable.

And no, i don't want to make .parent draggable instead of .draggable, since it's gonna be a window which will only be draggable in one place.

like image 215
Linas Avatar asked Jul 29 '12 21:07

Linas


1 Answers

Are you trying to make the child element a drag handle?

$(".parent").draggable({ handle: ".draggable" });

This would make it so the whole parent drags but but only uses the draggable div as an anchor.

jsFiddle Demo

Reference:

http://jqueryui.com/demos/draggable/#handle

like image 116
specman Avatar answered Nov 16 '22 14:11

specman