#8820 closed bug (notabug)
.sortable('destroy') fails in widget.bridge with uncaught exception 'cannot call methods prior to initialization'.
Reported by: | fwdillema | Owned by: | fwdillema |
---|---|---|---|
Priority: | minor | Milestone: | 1.10.0 |
Component: | ui.sortable | Version: | 1.9.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
.sortable('destroy') fails with uncaught exception 'cannot call methods prior to initialization'.
This occurs when using jquery-ui 1.9.1 together with jquery-1.7.2. Upgrading jquery to 1.8 makes this issue disappear, but as jquery-ui claims it should work with jquery-1.6 and up, I still regard this a bug.
the exception occurs here in widget.bridge, because $.data( this, fullName ); returns nothing with jquery-1.7.2:
if ( isMethodCall ) {
this.each(function() {
var methodValue,
instance = $.data( this, fullName );
if ( !instance ) {
return $.error( "cannot call methods on " + name + " prior to initialization; " +
"attempted to call method '" + options + "'" );
}
Change History (5)
comment:1 Changed 10 years ago by
comment:2 Changed 10 years ago by
Component: | ui.widget → ui.sortable |
---|---|
Owner: | set to fwdillema |
Status: | new → pending |
I'm not seeing any problems: http://jsfiddle.net/pZX2f/
Please provide a reduced test case showing the problem.
comment:3 Changed 10 years ago by
Status: | pending → new |
---|
My apologies, I attributed the bug to the wrong plugin. It was the plugin that used sortable that was wrong and called destroy multiple times.
The caller tried to destroy sortable only when it thought sortable was initialized on an element, something like:
if ($('#sortable').sortable) {
$('#sortable').sortable('destroy');
}
Maybe this used to work, but the above check now remains true after destroy has been called and thus the check is not doing its job.
comment:4 Changed 10 years ago by
Resolution: | → notabug |
---|---|
Status: | new → closed |
That check has never been correct. That checks if the sortable plugin exists, not if a specific instance exists. The correct check is $( "#sortable" ).data( "ui-sortable" )
.
comment:5 Changed 10 years ago by
In my case, I use: jQuery UI - v1.9.2, and I have only:
$this.sortable("destroy");
and I get: Uncaught Error: cannot call methods on sortable prior to initialization; attempted to call method 'destroy'
And I fixed when add the validation:
if ($this.data( "ui-sortable" )) { $this.sortable("destroy"); }
I was mistaken; upgrading jquery to 1.8 did not fix the issue.