I am trying to create a drap-drop using jquery UI. I want that dragable should revert to its position as soon as it gets out of dropable area. The problem here is the dragable gets stick to dropable after I drop it. Also I want to know how we can check that which dragable is dropped inside dropable.
HTML:
<div class = 'dragableContainer'>
<div class = 'dragable'></div>
<div class = 'dragable'></div>
<div class = 'dragable'></div>
<div class = 'dragable'></div>
</div>
<div class = 'dropableContainer'>
<div class = 'dropable'></div>
<div class = 'dropable'></div>
<div class = 'dropable'></div>
<div class = 'dropable'></div>
</div>
jquery:
$(document).ready(function(){
$( "div.dropable" ).droppable({
accept: "div.dragable",
tolerance: "intersect",
out: function( event, ui ) {
console.log("I am out")
},
over: function( event, ui ) {
console.log('I am over')
}
});
$( "div.dragable" ).draggable({
revert: "invalid"
});
});
CSS:
div.dropable {
width: 150px;
height: 150px;
border: 5px solid;
float: left;
margin: 10px;
}
div.dragable {
border: 5px solid;
float: left;
border: 5px solid;
width: 70px;
height: 70px;
margin: 10px;
}
div.dragableContainer {
height: 100px;
}