Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery-UI draggable error 'cannot call methods prior to init', in updating to version 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);

but could simply use

$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:

Error: cannot call methods on draggable prior to initialization; attempted to call method '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?

like image 483
user961627 Avatar asked Feb 19 '13 10:02

user961627


1 Answers

The meaning of your error is : $this.draggable('enable'); is called before $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.

like image 117
LeGEC Avatar answered Oct 13 '22 20:10

LeGEC