获取放置元素的项目/对象

jav*_*las 7 javascript jquery jquery-ui jquery-ui-sortable

我正在编写一个包含三个列表的任务面板,我使用sortable来在它们之间移动项目.但是我需要拿起放下元素的项目.我知道这ui.item是元素掉落,但我不知道我放弃了什么.这是我的代码:

$( ".column" ).sortable({
    receive: function(event, ui) {
        /* get the element where ui.item is dropped */
    }
});
Run Code Online (Sandbox Code Playgroud)

我知道元素将是任何.column选择器,但如何选择!

Nic*_*tti 7

编辑 - 一种方法就是这样

$("#sortable1, #sortable2").sortable({
    connectWith: ".connectedSortable",
    receive: function(e, ui) {
        alert(ui.item.closest('ul').attr('id'));

    }
}).disableSelection();
Run Code Online (Sandbox Code Playgroud)

当然,如果你不想让你所做的掉落元素旁边的元素

ui.item.closest('ul')
Run Code Online (Sandbox Code Playgroud)

在这里摆弄http://jsfiddle.net/dKaYM/


Ale*_*its 4

很简单的:

alert($(this).attr('id')); //this is element where the item was dropped in 
Run Code Online (Sandbox Code Playgroud)