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.

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


Need Your Help

Getting CGRect from array

objective-c ios nsarray cgrect

For my application I am trying to store CGRect objects into an NSMutableArray. It is loading well and printing in the log statement, but trying to take the CGRects from the array shows an error. He...

QTableView has unwanted checkboxes in every cell

c++ qt qt4 qtableview

I'm just getting started with Qt programming, and I'm trying to make a simple tabular data layout using a QTableView control with a model class of my own creation inheriting from QAbstractTableMode...