jQuery UI 可拖放浮动返回
我正在使用 jQuery UI 可拖/可放构建一个应用程序。
我需要将左侧的框拖到右侧的目标框中。它工作正常,但是如果值框 id 没有落在任何目标框上,则它需要浮回到左侧部分。
如果我稍微拖动它然后释放它,它就会起作用,但当它离得更远时,它就坐在那里。我已经添加了
$(".card").draggable({ revert: "invalid" });
,但似乎没有帮助。我缺少什么?
这是演示。
I am building an app utilizing jQuery UI draggable/droppable.
I need to drag boxes from the left into target boxes on the right. It works fine, however if a value box id dropped not on any target boxes it needs to float back into the left-side section.
It sort of works if I drag it a little and then release but when it is further away it just sits there. I've added
$(".card").draggable({ revert: "invalid" });
but it does not seem to help. What am I missing?
Here's DEMO.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为根据您的演示,您的可拖动功能不会恢复,因为它实际上击中了有效的可放置目标(演示中的 #dropZone 元素,本质上是背景)。
您可以通过不将该元素转换为可放置元素或使其放置处理程序“恢复”可拖动元素本身来修复此问题。
I think based on your demo that your draggable is not reverting because it's actually hitting a valid droppable target (the #dropZone element in your demo, which is essentially the background).
You can fix it by not turning that element into a droppable or by making it's drop handler "revert" the draggable element itself.