jquery拖放,删除和克隆,找到元素的删除位置
在这里,我是jquery拖放,删除和克隆function的小提琴。
问题:
我的问题是:当我丢弃元素时,它显示:
position: {top: 0, left: 0}
仅适用于draggable,clone和droppable元素。
我还编写了仅使用draggable
function查找位置的代码,并且工作正常。 我希望这种行为在draggable, droppable with clone feature
放置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;
参考: 如何在使用jQuery拖放后获取坐标位置?
用工作示例更新了Jsfiddle