问题描述
我已经尝试过执行任何操作,但是始终会收到相同的错误
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可拖动启用和禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!