I have two related sortable lists. My code works fine when I drag one item from the list on the left to the one on the right, but can you tell me what event I should look for if I want to know the order of the items in the left list when the item is dragged and deleted in the same list (basically, reorder items in the same list without dragging them to another list, but in the same list).
Thanks.
Edit:
Here is the link to the code: http://jsfiddle.net/Hitman666/WEa3g/1/
So, as you will see, I have a warning when items are dragged and dropped in oposite lists, but I also need an event when the list (like green) gets reordered. Then I will need to warn the order, for example: 4,3,2,1
HTML:
<ul id="sortable1" class="connectedSortable"> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> <li>Item 4</li> </ul> <ul id="sortable2" class="connectedSortable"> <li>Item 5</li> <li>Item 6</li> <li>Item 7</li> <li>Item 8</li> </ul>
CSS
#sortable1, #sortable2 { list-style-type: none; margin: 0; padding: 0; float: left; margin-right: 10px; } #sortable1 li, #sortable2 li { margin: 0 5px 5px 5px; padding: 5px; font-size: 1.2em; width: 120px; } #sortable1 li{background: green;} #sortable2 li{background: yellow;}
JavaScript:
$(function() { $("#sortable1, #sortable2").sortable({ connectWith: ".connectedSortable", receive: myFunc }).disableSelection(); function myFunc(event, ui) { alert(ui.item.html()); } });
source share