在更新到版本1.10.1时,jQuery-UI可拖动错误'无法在init之前调用方法' [英] jQuery-UI draggable error 'cannot call methods prior to init', in updating to version 1.10.1
问题描述
我在使用jQuery-UI 1.8.2时正在使用draggable插件,然后我改为1.10.1。我发现的主要区别是在启用和禁用插件时,我不再需要使用:
I was working the draggable plugin fine while using jQuery-UI 1.8.2, then I changed to 1.10.1. The major difference I found was that in enabling and disabling the plugin, I no longer needed to use:
$this.draggable('option', 'disabled', true);
但可以简单地使用
$this.draggable('disable');
但后来我意识到还有另一个问题。我收到此错误,这会弄乱我的整个程序,我不知道如何修复它:
But then I realized there's another problem. I get this error, which messes up my entire program, and I don't know how to fix it:
错误:无法调用方法在初始化之前可拖动;
试图调用方法'enable'
Error: cannot call methods on draggable prior to initialization; attempted to call method 'enable'
为了解决这个问题,我确保我总是打电话给 $ this.draggable('enable');
在任何进一步的选项之前,但它没有什么区别。有什么问题?
To fix it, I ensured that I always call $this.draggable('enable');
before any further options, but it didn't make a difference. What's the problem?
推荐答案
你的错误的含义是: $ this.draggable('enable' );
在 $ this.draggable();
之前调用。
The meaning of your error is : $this.draggable('enable');
is called before $this.draggable();
.
检查你的程序的执行流程:确保你在尝试用它做任何事情之前确实初始化了插件(例如:叫做 $ this.draggable();
)。
Check the execution flow of your progam : make sure that you have indeed initialized the plugin (e.g : called $this.draggable();
) before trying to do anything with it.
这篇关于在更新到版本1.10.1时,jQuery-UI可拖动错误'无法在init之前调用方法'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!