Reputation: 2735
I have a jQuery sortable list of unknown size and I need to update the item ordering when a item is re-positioned. I have the items position showing and I have the position updating when the item is moved however when an item is moved the other positions are not updated. For example, if my sortable list has 3 items with ordering 1, 2, 3 and I decide to move item 2 to position 3 the new ordering is 1, 3, 3. I want it to update to 1, 2, 3. Any ideas how I can achieve this? Here is my code for updating the position. Thanks.
$("#sortable2").sortable({
stop: function(event, ui) {
var id = $(ui.item).attr('id');
$("#" + id).html(ui.item.index() + 1);
}
});
Upvotes: 0
Views: 333