Jquery UI Sortable - Get the item being sorted

自闭症网瘾萝莉.ら 提交于 2019-11-30 00:45:17

问题


When using Jquery UI Sortable (which is great by the way) how do you get the item that is currently being sorted.

When you use $(this); it return the actual sortable list, not the current sorted item.

I want to do fancy-pants things with the widget when the user is dragging it around. E.g. Animate it when dragging between two lists.

So how do I get the current item being sorted?

There a little code below just to explain a little more...

$(function() {
    $("#sortable_1").sortable({
        start : function(event, ui){ 
            //get current element being sorted
        },
        stop : function(event, ui){ 
            //get current element being sorted
        }
    }).disableSelection();
});

回答1:


As far as I'm aware ui in your start: function(event, ui) is the current element being sorted.

As pointed out in the comments ui.item is the current element.



来源:https://stackoverflow.com/questions/2850961/jquery-ui-sortable-get-the-item-being-sorted

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!