In the JQueryUI draggable demo, I can see you can attach a handle to a DIV but if the handle is not nested within the parent DIV that is draggable, it doesn’t work e.g.
<script src="jquery-1.5.2.js"></script>
<script src="js/jquery-ui-1.8.11.custom.min.js"></script>
<style>
#hBlack
{
width:55px;
height:55px;
background-color: black;
top:0px;
}
#hGreen
{
width:25px;
height:25px;
background-color: green;
}
</style>
<script language="javascript" type="text/javascript">
$(function() {
$("#hBlack").draggable({handle:"#hGreen"});
});
</script>
</head>
<body>
<div id="hBlack">
</div>
<div id="hGreen"></div>
The above doesn’t make #hGreen the handle – but the following does:
<div id="hBlack">
<div id="hGreen"></div>
</div>
Essentially, I am trying to make one DIV move when another moves – I guess you can do it with the new Position utility but for a newbie like me I find it poorly documented
One possible solution could be to have the handle inside, but use css to position it outside.
Javascript:
HTML:
CSS:
Otherwise, you might have to do something similar to a multiselect draggable.
How do I drag multiple elements at once with JavaScript or jQuery?