0

I am dragging an element (draggable) inside another one (droppable), when it drops, it clones the object to the droppable div. But with no position info, so the cloned object is 0 left and 0 top. My code is as follows:

$('#objects div').draggable({revert: 'invalid', helper: 'clone'});
$('#objects').droppable({});
$('.ace').droppable({
    drop:function(e, ui){

        var clone = $(ui.draggable).clone();
        var parent = $('.ace');

        ui.draggable.detach();
        clone.appendTo(parent);

    }               
});

I know i should calculate the dragged object position against the container position and set the data into the clone position, but I can`t get the dragged object position from the droppable method, neither I could clone the object from the draggable method properly.

What am I missing? Thanks in advance!

4

1 回答 1

1
e.pageX 
e.pageY

将有被放置元素的位置信息,做一个console.log(e)看看你能从 ei 对象中得到什么

于 2013-10-18T16:07:53.377 回答