Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the item/object where the element is dropped

I'm coding a task panel with three lists and I use sortable to move item between them. But I need to pick up the item where the element is dropped. I know that ui.item is the element dropped, but I don't know where I dropped it. Here is my code:

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

I know that the element will be any with the .column selector, but how to pick!!!

like image 815
javimaravillas Avatar asked Mar 06 '12 13:03

javimaravillas


2 Answers

EDIT - a way to do that is like this

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

    }
}).disableSelection();

Of course if you wan't to get the element next to the dropped element you'd do

ui.item.closest('ul')

fiddle here http://jsfiddle.net/dKaYM/

like image 150
Nicola Peluchetti Avatar answered Sep 19 '22 16:09

Nicola Peluchetti


Very Simple:

alert($(this).attr('id')); //this is element where the item was dropped in 
like image 43
Alex Shuraits Avatar answered Sep 21 '22 16:09

Alex Shuraits