OK, what I want to create is: draggable elements which fit in table cells (.slot divs). Here is a simplified version of my code with jQuery UI:
<style>
.draggable, .cell {
width: 100px; height: 100px;
}
.cell {
background: #F00;
}
</style>
<script type="text/javascript">
$(function() {
$( ".draggable" ).draggable({
distance: 20,
containment: "#container",
snap: ".slot",
snapMode: "inner",
snapTolerance: 10,
});
});
</script>
<table id=”container”>
<tr>
<td class=”cell”> <div class=”slot”> <div class=”draggable”></div> </div> </td>
<td class=”cell”> <div class=”slot”></div> </td>
</tr>
<tr>
<td class=”cell”> <div class=”slot”> <div class=”draggable”></div> </div> </td>
<td class=”cell”> <div class=”slot”></div> </td>
</tr>
<tr>
<td class=”cell”> <div class=”slot”></div> </td>
<td class=”cell”> <div class=”slot”></div> </td>
</tr>
</table>
Since now I am able to move them around the cells (.slot) but I can’t achieve two things:
Any suggestions or help is appreciated!
Thanks in advance, George
Try using jQuery UI Sortable instead of Draggable. You may need to use Sortable-Connected Lists in your case.