[jQuery] Draggable containment not rebinding
I'm trying to make it so I can drag a square which is confined to
0,0,50,0. When they stop dragging it I simply want to change the
confinement to 0,0,100,100 the next time they drag. Not sure why it
doesn't work though.
Here is the code:
Code:
[code]
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://jqueryui.com/latest/
jquery-1.3.2.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/
ui.core.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/
ui.draggable.js"></script>
<style type="text/css">
#draggable
{
width: 25px;
height: 25px;
background: lightgreen;
border: 1px solid black;
cursor: pointer;
cursor: hand;
}
</style>
<script type="text/javascript">
$(document).ready(function()
{
$('#draggable').draggable({containment: [0, 0, 50,
50]});
$('#draggable').bind('dragstop', function(event, ui)
{
$("#draggable").draggable({ containment: [0, 0, 100,
100] });
});
});
</script>
</head>
<body style="font-size:62.5%;">
<div id="containmentParent" style="position: absolute; top:
20px; left: 20px; width: 150px; height: 150px; background-color:
#eeeeee; border: 1px solid black;">
<div id="draggable">Drag me</div>
<div>
</body>
</html>
[/code]
Thanks for the help!