jQuery可拖动启用和禁用 [英] jquery draggable enable and disable

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

问题描述

我已经尝试过执行任何操作,但是始终会收到相同的错误

Ive tried anything to do this, but always get the same error

$(".tooltip").draggable('disable');

错误:初始化前无法在可拖动对象上调用方法;尝试将方法称为禁用"

Error: cannot call methods on draggable prior to initialization; attempted to call method 'disable'

在初始化之前?因此,我无法在实际拖动该选项之前将其删除?香港专业教育学院也尝试过droppable,似乎无法禁用它们而没有得到此错误.

Prior to initialization? So I cannot remove the option before its actually being dragged around? Ive tried with droppable as well, cant seem to get them disabled enabled without getting this error.

我发现我的类中有一个不可拖动的元素(当您查看错误时这很有意义).现在,我只需要找到一种方法,即可禁用所有可拖动对象而不会引发错误:)

edit: I found out that I have an element with the class that is without draggable (which makes sense when you look at the error). Now I just have to find a way so it disables all the draggables without throwing the error :)

推荐答案

尝试一下:

$(".tooltip").draggable({ disabled: true });

这将在可禁用状态下初始化可拖动对象.然后,您可以使用

This initializes the draggable in the disabled state. You can then use

$(".tooltip").draggable("enable");

稍后要允许拖动时.

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

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