Skip to main content

Search and Top Navigation

#7221 closed bug (worksforme)

Opened April 05, 2011 08:48PM UTC

Closed April 06, 2011 10:16AM UTC

Last modified April 07, 2011 01:37PM UTC

containment breaks sortable

Reported by: jbliss Owned by:
Priority: minor Milestone: 1.9.0
Component: ui.sortable Version: 1.8.11
Keywords: Cc:
Blocked by: Blocking:
Description

SEE: http://jsfiddle.net/2bsFK/

...and watch what happens on drag.

NOTE: This is simply http://jqueryui.com/demos/sortable/display-grid.html with line 19 changed to:

$( "#sortable" ).sortable({ containment: 'parent' });

Attachments (0)
Change History (4)

Changed April 06, 2011 10:16AM UTC by rdworth comment:1

resolution: → worksforme
status: newclosed

This is not actually a bug. You're trying to contain in an element with height:0 because all it's children are floated and it is not. Simply give the parent element (the UL) a height or set it to float:left and it works. See: http://jsfiddle.net/2bsFK/1/

Changed April 06, 2011 01:25PM UTC by jbliss comment:2

Thanks! Recommend this change (or similar) on http://jqueryui.com/demos/sortable/#display-grid This:

Constrains dragging to within the bounds of the specified element - can be a DOM element, 'parent', 'document', 'window', or a jQuery selector.

...should read:

Constrains dragging to within the bounds of the specified element - can be a DOM element, 'parent', 'document', 'window', or a jQuery selector. NOTE: if you specify a DOM element, 'parent', or a jQuery selector, be sure to give the parent element (in the demo, the ul id="sortable") a height or set it to float:left.

Changed April 07, 2011 01:32PM UTC by rdworth comment:3

_comment0: While I'm sorry you ran into this issue, some good came of it in the end. I was struggling with how to fix a [http://core.trac.wordpress.org/ticket/16955 WordPress issue] that we caused by fixing #4551 way back in 1.8a1. It turns out this was the root cause there as well, making the ticket invalid, assuring us our "fix" was invalid. Thanks to just having run into this with you this week I was able to recognize it. \ \ Also, your suggestion on updating the documentation is a good one. I added a note to http://docs.jquery.com/UI/API/1.8/Sortable#option-containment it will show up on jqueryui.com the next time the site is updated, for the 1.8.12 release.1302183181407870

While I'm sorry you ran into this issue, some good came of it in the end. I was struggling with how to fix a WordPress issue that we caused by fixing #4551 way back in 1.8a1. It turns out this was the root cause there as well, making the ticket invalid, assuring us our "fix" was invalid. Thanks to having just run into this with you this week I was able to recognize it.

Also, your suggestion on updating the documentation is a good one. I added a note to http://docs.jquery.com/UI/API/1.8/Sortable#option-containment . It will show up on jqueryui.com the next time the site is updated, for the 1.8.12 release.

Changed April 07, 2011 01:37PM UTC by jbliss comment:4

Excellent!