Opened 12 years ago
Closed 10 years ago
#5959 closed bug (invalid)
"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 (last modified by )
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
Change History (5)
comment:1 Changed 12 years ago by
Priority: | blocker → major |
---|
comment:2 Changed 10 years ago by
Milestone: | TBD → 2.0.0 |
---|
comment:3 Changed 10 years ago by
Description: | modified (diff) |
---|
comment:4 Changed 10 years ago by
Owner: | set to kamity |
---|---|
Status: | new → pending |
comment:5 Changed 10 years ago by
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!
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.