I have a draggable list (.field) where you can drag items from it to a sortable list (.sortlist). I did it this way because I did not want the main list (.field) to somehow change. It works fine, but I cannot figure out how to manipulate a discarded field in a sorted list.
I can make this from being dragged to the area resettable by using the following in the function for "drop:" in droppable ():
$(this).append('html code here to change content of dragged field');
However, this does not work inside sortable (). My code is as follows:
$(".sortlist").sortable({ receive: function(event, ui) { var dropElemTxt = $(ui.item).text(); var dropElemId = $(ui.item).attr('id'); $(ui.item).replaceWith('<li class="box" id="'+dropElemId+'">Updated field! '+dropElemTxt+'</li>'); } });
$ (ui.item) .replaceWith changes the main field that is being dragged, so this does not work. And I tried $ (this) .replaceWith, but this updates the sorted area (.sortlist).
Any idea what code I need to reference the item being dragged?
Thanks a lot, Ali.
jquery list replace jquery-ui-sortable
Wasted space
source share