簡體   English   中英

獲取放置元素的項目/對象

[英]Get the item/object where the element is dropped

我正在編寫一個包含三個列表的任務面板,我使用sortable來在它們之間移動項目。 但是我需要拿起放下元素的項目。 我知道ui.item是丟棄的元素,但我不知道我放棄了它。 這是我的代碼:

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

我知道元素將是.column選擇器的任何元素,但如何選擇!

編輯 - 一種方法就是這樣

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

    }
}).disableSelection();

當然,如果你不想讓你所做的掉落元素旁邊的元素

ui.item.closest('ul')

在這里擺弄http://jsfiddle.net/dKaYM/

很簡單:

alert($(this).attr('id')); //this is element where the item was dropped in 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM