Search and Top Navigation
#5959 closed bug (invalid)
Opened August 16, 2010 07:01PM UTC
Closed November 20, 2012 08:51AM UTC
"offsetParent[0] is undefined" error in sortable
Reported by: | kamity | Owned by: | kamity |
---|---|---|---|
Priority: | major | Milestone: | 2.0.0 |
Component: | ui.sortable | Version: | 1.8.4 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I have a draggable list on the page, whose items are connected to multiple sortable lists using 'connectToSortable'. When I drag the first element and drop in to one of the sortables, it works fine. But on subsequent operations, the drag/drop fails with the following errors in the FF (3.6.8) console.
Error: this.offsetParent[0] is undefined Source File: http://www.ship.989studios.com/js/jquery/ui/jquery-ui-1.8.4.custom.js Line: 3871 Error: scroll[0] is undefined Source File: http://www.ship.989studios.com/js/jquery/ui/jquery-ui-1.8.4.custom.js Line: 3960
After changing the method _getParentOffset in jquery-ui-1.8.4.custom.js as follows, it works fine. Is this a valid fix?
_getParentOffset: function() { //Get the offsetParent and cache its position this.offsetParent = this.helper.offsetParent(); var po = this.offsetParent.offset(); // This is a special case where we need to modify a offset calculated on start, since the following happened: // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) { po.left += this.scrollParent.scrollLeft(); po.top += this.scrollParent.scrollTop(); } var isOffsetParentFound = (this.offsetParent != null && this.offsetParent[0] != null); if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information || (isOffsetParentFound && this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix po = { top: 0, left: 0 }; if (po == null) { po = { top: 0, left: 0 }; } return { top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0), left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0) }; }
Thanks
Attachments (0)
Change History (5)
Changed October 19, 2010 03:23PM UTC by comment:1
priority: | blocker → major |
---|
Changed October 11, 2012 09:07PM UTC by comment:2
milestone: | TBD → 2.0.0 |
---|
Changed November 05, 2012 11:46PM UTC by comment:3
description: | I have a draggable list on the page, whose items are connected to multiple sortable lists using 'connectToSortable'. When I drag the first element and drop in to one of the sortables, it works fine. But on subsequent operations, the drag/drop fails with the following errors in the FF (3.6.8) console. \ \ Error: this.offsetParent[0] is undefined \ Source File: http://www.ship.989studios.com/js/jquery/ui/jquery-ui-1.8.4.custom.js \ Line: 3871 \ \ Error: scroll[0] is undefined \ Source File: http://www.ship.989studios.com/js/jquery/ui/jquery-ui-1.8.4.custom.js \ Line: 3960 \ \ After changing the method _getParentOffset in jquery-ui-1.8.4.custom.js as follows, it works fine. Is this a valid fix? \ \ _getParentOffset: function() { \ \ //Get the offsetParent and cache its position \ this.offsetParent = this.helper.offsetParent(); \ var po = this.offsetParent.offset(); \ \ // This is a special case where we need to modify a offset calculated on start, since the following happened: \ // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent \ // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that \ // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag \ if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) { \ po.left += this.scrollParent.scrollLeft(); \ po.top += this.scrollParent.scrollTop(); \ } \ var isOffsetParentFound = (this.offsetParent != null && this.offsetParent[0] != null); \ \ if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information \ || (isOffsetParentFound && this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix \ po = { top: 0, left: 0 }; \ if (po == null) \ { \ po = { top: 0, left: 0 }; \ } \ \ return { \ top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0), \ left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0) \ }; \ \ } \ \ Thanks \ → I have a draggable list on the page, whose items are connected to multiple sortable lists using 'connectToSortable'. When I drag the first element and drop in to one of the sortables, it works fine. But on subsequent operations, the drag/drop fails with the following errors in the FF (3.6.8) console. \ \ {{{ \ Error: this.offsetParent[0] is undefined \ Source File: http://www.ship.989studios.com/js/jquery/ui/jquery-ui-1.8.4.custom.js \ Line: 3871 \ \ Error: scroll[0] is undefined \ Source File: http://www.ship.989studios.com/js/jquery/ui/jquery-ui-1.8.4.custom.js \ Line: 3960 \ }}} \ \ After changing the method _getParentOffset in jquery-ui-1.8.4.custom.js as follows, it works fine. Is this a valid fix? \ {{{ \ _getParentOffset: function() { \ \ //Get the offsetParent and cache its position \ this.offsetParent = this.helper.offsetParent(); \ var po = this.offsetParent.offset(); \ \ // This is a special case where we need to modify a offset calculated on start, since the following happened: \ // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent \ // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that \ // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag \ if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) { \ po.left += this.scrollParent.scrollLeft(); \ po.top += this.scrollParent.scrollTop(); \ } \ var isOffsetParentFound = (this.offsetParent != null && this.offsetParent[0] != null); \ \ if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information \ || (isOffsetParentFound && this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix \ po = { top: 0, left: 0 }; \ if (po == null) \ { \ po = { top: 0, left: 0 }; \ } \ \ return { \ top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0), \ left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0) \ }; \ \ } \ }}} \ Thanks \ |
---|
Changed November 05, 2012 11:54PM UTC by comment:4
owner: | → kamity |
---|---|
status: | new → pending |
Thanks for taking the time to contribute to the jQuery UI project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.
Additionally, be sure to test against the git version of both jQuery UI and jQuery to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/ZgAqH/ Open the link and click to "Fork" (in the top menu) to get started.
Changed November 20, 2012 08:51AM UTC by comment:5
resolution: | → invalid |
---|---|
status: | pending → closed |
Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!