Opened 14 years ago

Closed 10 years ago

Last modified 9 years ago

#4904 closed bug (worksforme)

Sortable: Error "this.helper.0 is null or not an object" when dropping object

Reported by: rgurganus Owned by:
Priority: major Milestone: 2.0.0
Component: ui.sortable Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:

Description

In IE6 and IE7: When dragging and dropping a sortable, IE sometimes returns this error: "this.helper.0 is null or not an object" Looking at the debugger, it is in jquery-ui.js on this line:

if(this.helper[0] == this.currentItem[0]) {

I was able to see this same error on the live demo here, though I can't say what sequence of dragging and dropping led to the error happening. http://jqueryui.com/demos/draggable/#sortable

In my application, it happens with every drag & drop. I can post code if needed, but if it's happening on yours, maybe you don't need my code.

Same results in both 1.7.2 and 1.8a1

Change History (12)

comment:1 Changed 14 years ago by Jörn Zaefferer

Component: ui.coreui.sortable
Milestone: TBD1.8

comment:2 Changed 13 years ago by karlgoldstein

I am experiencing the same error with 1.8.2. Looking at the _clear function of jquery.ui.sortable.js, I see this on line 1030:

if(this.helper[0] != this.currentItem[0]) this.helper.remove(); this.helper = null;

and am wondering whether there it should be:

if(this.helper[0] != this.currentItem[0]) { this.helper.remove(); this.helper = null; }

otherwise the helper is unexpectedly getting set to null?

comment:3 Changed 12 years ago by Scott González

#7372 is a duplicate of this ticket.

comment:4 Changed 11 years ago by earachefl

I'm having the same error in jquery-ui-1.8.24.custom.js (all modules). Changing line 4343 from:

this.placeholder[0].parentNode.removeChild(this.placeholder[0]);

to:

if(this.placeholder[0].parentNode){this.placeholder[0].parentNode.removeChild(this.placeholder[0]);}

and line 4345 from:

if(this.helper[0] != this.currentItem[0]) this.helper.remove(); this.helper = null;

to:

if (this.helper && this.helper[0] != this.currentItem[0]) {this.helper.remove();this.helper = null;}

gets rid of the IE8 javascript error message, but as I haven't dug very deeply into the code, I don't know whether there might be any unintended consequences.

comment:5 Changed 11 years ago by Scott González

Milestone: 1.9.02.0.0

comment:6 Changed 11 years ago by petersendidit

#6954 is a duplicate of this ticket.

comment:7 Changed 11 years ago by petersendidit

Status: newopen
Summary: Error "this.helper.0 is null or not an object" when dropping objectSortable: Error "this.helper.0 is null or not an object" when dropping object

comment:8 Changed 10 years ago by tj.vantoll

Resolution: worksforme
Status: openclosed

I cannot recreate this issue. This demo specified shows no issues in IE 7 - 9 on http://jqueryui.com. Duplicate #7372 relies on a JS error for a bug to occur, and #6954 is a separate issue.

If anybody watching this is still experiencing this issue please create a reduced test case that shows this. You can use this as a starting point http://jsfiddle.net/tj_vantoll/wjxe4/.

comment:9 Changed 9 years ago by briansol

In ie8, I'm getting this bug when using the beforeStop event on linked lists with 1 being a source pool to drag onto other linked sortable lists. (Prevents putting it back into the pool).

  'this.helper.0' is null or not an object  jquery-ui-1.10.3.custom.min.js, line 6 character 88042

Chrome also throws a different error when using the above linked fiddle, modded to do the same thing:

Uncaught TypeError: Cannot call method 'removeChild' of null jquery-ui-git.js:4986
$.widget._clear jquery-ui-git.js:4986
(anonymous function) jquery-ui-git.js:392
$.widget._mouseStop jquery-ui-git.js:4181
(anonymous function) jquery-ui-git.js:392
$.widget._mouseUp jquery-ui-git.js:980
(anonymous function) jquery-ui-git.js:392
_mouseUpDelegate jquery-ui-git.js:931
jQuery.event.dispatch jquery-git.js:4628
elemData.handle

sample fiddle forked from above given: http://jsfiddle.net/briansol/wjxe4/49/

Version 0, edited 9 years ago by briansol (next)

comment:10 Changed 9 years ago by tj.vantoll

The docs state to use cancel() in a stop event rather than a beforeStop one, and when I do that this example works fine in Chrome and IE8: http://jsfiddle.net/tj_vantoll/P4aVc/.

comment:11 Changed 9 years ago by briansol

Thanks for that, it does seem to do the trick. I can't seem to find the documentation that says that, though. Can you provide a link to that? Appreciate it.

comment:12 in reply to:  11 Changed 9 years ago by tj.vantoll

Replying to briansol:

Thanks for that, it does seem to do the trick. I can't seem to find the documentation that says that, though. Can you provide a link to that? Appreciate it.

http://api.jqueryui.com/sortable/#method-cancel ("Useful in the stop and receive callback functions.")

And no problem.

Note: See TracTickets for help on using tickets.