Opened 11 years ago
Last modified 10 years ago
#8180 open bug
Sortable: Error when there are items in the sortable container that are already a sortable
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | minor | Milestone: | 2.0.0 |
Component: | ui.sortable | Version: | 1.8.18 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
In this example --> http://jsfiddle.net/4p8b6/
We configure some containers and items, and apply only the sortable widget to the containers, but one container is also "sortable", so we can move items between all containers.
Everything works ok, except when I move the inner container outside the parent boundaries, then the inner container dissapears and the following exception occur "5779Uncaught Error: HIERARCHY_REQUEST_ERR: DOM Exception 3"
I tried to solve it adding some conditions to _clean method in sortable widget
Original:
if (!this._noFinalSort && this.currentItem[0].parentNode) this.placeholder.before(this.currentItem);
Changed
if (!this._noFinalSort && this.currentItem[0].parentNode && this.currentItem[0].parentNode && this.currentItem[0].parentNode.tagName != null && this.placeholder[0].parentNode[$.expando] != this.currentItem[0][$.expando]) { this.placeholder.before(this.currentItem); }
Hope this helps.
Thanks in advance
Regards Diego Parra
Change History (3)
comment:1 Changed 10 years ago by
Milestone: | 1.9.0 → 2.0.0 |
---|
comment:2 Changed 10 years ago by
Status: | new → open |
---|
comment:3 Changed 10 years ago by
Summary: | Sortable does not work properly when there are items in the sortable container that are already a sortable → Sortable: Error when there are items in the sortable container that are already a sortable |
---|
Note: See
TracTickets for help on using
tickets.
Updated test case against master: http://jsfiddle.net/tj_vantoll/CPEG8/. Drag the inner container outside of the outer container to see the error.
I can confirm that the error is coming from this line in
_clear
on this line https://github.com/jquery/jquery-ui/blob/44d07173db32b498e5f83f60db290ff1463daee3/ui/jquery.ui.sortable.js#L1155.The error is occurring because the plugin ends up trying to append the item to itself. To avoid this the following check could be added:
{{{this.placeholder[0].parentNode !== this.currentItem[0]}}
I can't think of any adverse effects of this.