开发者

How can I get new cloned item in jQuery Sortable receive function

开发者_Python百科

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;
  }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜