How can I get new cloned item in jQuery Sortable receive function
I'm dragging new item to sortable list, but when I call ui.item it points to original object. How can I get reference to new dropped object?
Link to same problem in jQuery forum:
http://forum.jquery.com/topic/sortable-receive-how-do-i-get-new-item
You could use update instead of receive to get a handle to the newly dropped object.
I've created a small demo that changes the color of the dropped object to red after dropping. It does rely on the class name of the clone to differentiate between a received clone and an internal sort (otherwise everything would end up red after sorting).
From jQuery UI 1.10 the way is this:
$('#sortable-list').sortable({
receive: function (event, ui) {
// New item
var droppedItem = $(this).data().uiSortable.currentItem;
}
});
精彩评论