销毁可拖动的JQuery [英] Destroy JQuery draggable

查看:80
本文介绍了销毁可拖动的JQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组可拖动的元素.如何删除可拖动功能?

I have a set of elements that are draggable. How can I remove draggable function?

    在我的情况下,
  1. $('.draggable').draggable('disable')不是一个选择

  1. $('.draggable').draggable('disable') is not an option in my case

$('.draggable').draggable('destroy')返回Uncaught TypeError: Cannot read property 'options' of undefined

推荐答案

通过jQuery UI API:

From the jQuery UI API:

destroy()

完全删除可拖动功能.这样会将元素返回到其初始状态.

Removes the draggable functionality completely. This will return the element back to its pre-init state.

This method does not accept any arguments.

代码示例:

调用destroy方法:

Invoke the destroy method:

$( ".selector" ).draggable( "destroy" );

编辑

由于这似乎对您而言不正确-这是在jQuery论坛中普遍出现的一个问题-这是建议的解决方法:

As this seems to not work properly for you - and it's an issue being seen all around the jQuery forums - that's a proposed fix:

ui.draggable.draggable("option", "revert", false);

这篇关于销毁可拖动的JQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆