jquery drag, drop and clone, find dropped position of element

后端 未结 1 1966
无人共我
无人共我 2021-01-06 10:24

Here, is my fiddle for jquery drag, drop and clone feature.

Problem:

My problem is: when ever I drop element, it is showing:



        
相关标签:
1条回答
  • 2021-01-06 10:56

    Finally, resolved the problem. The problem was, I was using ui.draggable.position(); for storing dropped position to database, which was wrong.

    The actual position we need to store is:

    // position of the draggable minus position of the droppable
    // relative to the document
    leftPosition  = ui.offset.left - $(this).offset().left;
    topPosition   = ui.offset.top - $(this).offset().top;
    

    Reference: How do I get the coordinate position after using jQuery drag and drop?

    Updated Jsfiddle with working example

    http://jsfiddle.net/przbadu/rkvdffe3/18/

    http://jsfiddle.net/przbadu/rkvdffe3/18/embedded/result/

    0 讨论(0)
提交回复
热议问题