使用 Jquery ui 的可拖动功能,如何更改停止时的恢复?
我想知道您如何更改从停止事件中拖动到 Jquery ui 中的某些内容的“恢复”属性。
$('.things').draggable({
revert: "true",
stop: function(event, ui){
//if something then set revert to false
}
});
我尝试了一些方法,但似乎无法让它发挥作用。
干杯。
I was wondering how you changed the "revert" property of something being dragged in Jquery ui from the stop event.
$('.things').draggable({
revert: "true",
stop: function(event, ui){
//if something then set revert to false
}
});
I've tried a few things but I can't seem to get it to work.
Cheers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
stop
事件发生得太晚,无法对revert
选项进行更改来影响当前的拖动操作。可拖动对象仍将恢复,即使在下一次拖动中不再这样做。您可能想绑定到 drag 事件:
The
stop
event occurs too late for changes to therevert
option to affect the current drag operation. The draggable will still revert, even if it won't do so anymore in the next drags.You might want to bind to the drag event instead:
我意识到自提出这个问题以来已经有一段时间了,但在 JQuery UI 1.10 及更高版本中,
draggable
现在支持将函数作为revert
的值。如果该值返回 true,则该位置将被恢复,否则不会。I realize this has been a while since this question was asked, but in JQuery UI 1.10 and above
draggable
now supports a function as a value forrevert
. If the value returns true then the position is reverted otherwise it does not.