Skip to content

Instantly share code, notes, and snippets.

@redknitin
Created October 5, 2015 06:01
Show Gist options
  • Save redknitin/309e2db9e68840f4bd85 to your computer and use it in GitHub Desktop.
Save redknitin/309e2db9e68840f4bd85 to your computer and use it in GitHub Desktop.
Draggable - Demo 2
<!doctype html><html lang="en">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script>
<style>
</style>
<script>
$(document).ready(function() {
$('#nit1').draggable({
revert: 'invalid', //Return to orig pos if not accepted by droppable
// revert: function(event, ui) {
// $(this).data('uiDraggable').originalPosition={top: 0, left: 0};
// return !event;
// },
cursor: 'move'
});
$('#nit10').draggable({
revert: 'invalid', //Return to orig pos if not accepted by droppable
cursor: 'move'
});
$('#nit2').droppable({
//accept: '#nit1', //To filter acceptance
drop: function(event, ui){ //Does the 'snap' UI thingie
//ui.draggable.position({of: $(this), my:'left top', at:'left top'});
alert('This is now that');
},
out: function(event, ui) {
//alert('Out!');
//ui.draggable.position({top: 0, left: 0});
}
});
$('#nit20').droppable({
});
});
</script>
</head>
<body>
<div style="background-color: green; padding: 3px; display: inline-block;">
<div id="nit2" style="height: 100px; width: 200px; background-color: white;">Box</div>
</div>
<div style="background-color: green; padding: 3px; display: inline-block;">
<div id="nit20" style="height: 100px; width: 200px; background-color: white;">
<div style="min-height: 50px; min-height: 50px; display: inline-block;">
<div id="nit1" style="height: 20px; min-width: 20px; background-color: red; display: inline-block;">Nitin</div>
<div id="nit10" style="height: 20px; min-width: 20px; background-color: red; display: inline-block;">Reddy</div>
</div>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment