prz*_*adu 4 jquery jquery-ui jquery-ui-draggable jquery-ui-droppable
在这里,我是jquery拖放,删除和克隆功能的小提琴.
问题:
我的问题是:当我丢弃元素时,它显示:
position: {top: 0, left: 0}
Run Code Online (Sandbox Code Playgroud)
仅适用于draggable,clone和droppable元素.
我还编写了仅使用draggable函数查找位置的代码,并且工作正常.我想要这种行为draggable, droppable with clone feature
请访问JSFiddle
最后,解决了这个问题.问题是,我ui.draggable.position();用于存储丢弃的位置到数据库,这是错误的.
我们需要存储的实际位置是:
// 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;
Run Code Online (Sandbox Code Playgroud)
用工作示例更新了Jsfiddle
http://jsfiddle.net/przbadu/rkvdffe3/18/
http://jsfiddle.net/przbadu/rkvdffe3/18/embedded/result/