Linas
Linas

Reputation: 4408

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.

Upvotes: 9

Views: 13053

Answers (1)

specman
specman

Reputation: 431

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

Upvotes: 25

Related Questions