Search and Top Navigation
#8820 closed bug (notabug)
Opened November 15, 2012 09:38PM UTC
Closed November 16, 2012 01:44PM UTC
Last modified July 04, 2013 02:35PM UTC
.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 + "'" );
}
Attachments (0)
Change History (5)
Changed November 15, 2012 09:44PM UTC by comment:1
Changed November 16, 2012 12:07AM UTC by comment:2
component: | ui.widget → ui.sortable |
---|---|
owner: | → fwdillema |
status: | new → pending |
I'm not seeing any problems: http://jsfiddle.net/pZX2f/
Please provide a reduced test case showing the problem.
Changed November 16, 2012 08:26AM UTC by comment:3
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.
Changed November 16, 2012 01:44PM UTC by comment:4
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" )
.
Changed July 04, 2013 02:35PM UTC by comment:5
_comment0: | 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"); } → 1372948643920215 |
---|
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.