/ Published in: JavaScript
A little snippet which allows simultaneous use of jquery sortable, draggable and droppable on the same element
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<script type="text/javascript"> $(function(){ addDraggableTo($('.weekplaner-task')); $('.weekplaner-daybox ul').droppable({}).sortable({ revert: true, stop: function(e,ui){ $(ui.item).attr('style',''); addDraggableTo(ui.item) } }); }); function addDraggableTo(sel){ sel.draggable({ containment:'#weekplaner-wrapper', connectToSortable: '.weekplaner-daybox ul', opacity: 0.7, helper: function(){ return this } }); } </script> <div id="weekplaner-wrapper"> <?php for($i = 1; $i <= 5; $i++){ ?> <div class="weekplaner-daybox"> <ul> <li class="weekplaner-task">remedia</li> <li class="weekplaner-task">remedia</li> </ul> </div> <?php } ?> <div class="clear"></div> </div>