Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#7221 closed bug (worksforme)

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' });

Change History (4)

comment:1 Changed 9 years ago by rdworth

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/

comment:2 Changed 9 years ago by jbliss

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.

comment:3 Changed 9 years ago by rdworth

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.

Last edited 9 years ago by rdworth (previous) (diff)

comment:4 Changed 9 years ago by jbliss

Excellent!

Note: See TracTickets for help on using tickets.