草庐IT

javascript - jQuery-UI draggable error 'cannot call methods prior to init' , 在更新到版本 1.10.1

coder 2024-05-15 原文

我在使用 jQuery-UI 1.8.2 时可以正常使用可拖动插件,然后我更改为 1.10.1。我发现的主要区别是在启用和禁用插件时,我不再需要使用:

$this.draggable('option', 'disabled', true);

但可以简单地使用

$this.draggable('disable');

但后来我意识到还有另一个问题。我得到这个错误,它弄乱了我的整个程序,我不知道如何修复它:

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

为了修复它,我确保在任何进一步的选项之前总是调用 $this.draggable('enable');,但这并没有什么不同。有什么问题?

最佳答案

你的错误的意思是:$this.draggable('enable'); is called before $this.draggable();.

检查您的程序的执行流程:确保您确实已经初始化了插件(例如:调用 $this.draggable();),然后再尝试对其进行任何操作。

关于javascript - jQuery-UI draggable error 'cannot call methods prior to init' , 在更新到版本 1.10.1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14955630/

有关javascript - jQuery-UI draggable error 'cannot call methods prior to init' , 在更新到版本 1.10.1的更多相关文章

随机推荐