jQuery-UI draggable error 'cannot call methods prior to init', in updating to version 1.10.1

喜你入骨 提交于 2019-12-05 03:43:22

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.

Expanding on what LeGEC said...

$this.draggable(); is being called before $this.draggable('enable');

For me the solution would be to chain the event like this...

$this.draggable().draggable('disable');

First declaring that $this is a draggable, then declaring that it is dissabled

I had a similar issue when upgrading from jquery 1.6.1 to 1.9.1

var tr$ = $('<tr>', { draggable: 'true' }); 

threw "cannot call methods on draggable prior to initialization"

modified to:

var tr$ = $('<tr>');
if(!('draggable' in document.createElement('span'))) {
  //handle old browsers                
} else {
  tr$.attr('draggable', 'true');
}

Posting in case it helps someone else to see it this way.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!