سؤال

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!

هل كانت مفيدة؟

المحلول

e.pageX 
e.pageY

will have the position information of the dropped element, do a console.log(e) to see what all you can get from the ei object

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top