views:

38

answers:

2

I want to drag item from one list to another list with clone. After stop dragging then i want to get id of parent div where it is dragged.

+1  A: 

It sounds to me like you need to use jQuery UI Droppable as well as Draggable.

The following code provides an example of how to use Droppable. It assumes the divs you want to allow items on have class name someClassName. When you drag an item onto one of the divs, it pops up an alert box with the ID of the div you dropped your item onto:

$(document).ready(function() {
    $("div.someClassName").droppable({
        drop: function(event, ui) {
            alert("You dropped an item onto a div with ID '" + event.target.id + "'");
        }
    });
});
Pourquoi Litytestdata
+2  A: 

By using draggable and droppable, you can do i like this (Given that your ul's have the class draggables):

$("ul.draggables").droppable({
    drop: function() { alert($(this).parents("div:first").attr("id")) }
})
.find("li")
.draggable({
    helper: "clone"
});

Here's a demo: http://jsfiddle.net/5s5rt/1/

Edit: modified to find the first of the list's parents with type div, in case the div isn't it's immediate parent.

Simen Echholt
Thanks you have solved my problem.Thanks again.
Xulfee