Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>We had success resolving a similar (but not identical) issue using the <code>change</code> option of the the <code>sortable</code> function. Our problem was that we had some "tall" LI elements in the two column list, and when those tall elements were in the first column, other items would pile up in the second column adjacent to the tall elements since all the LI elements were <code>float: left</code>. This would make for very strange interaction when sorting.</p> <p>To get around the issue, you can apply <code>clear: both</code> to all the LI elements in the first column (all the odd elements), however things get screwy in the middle of a sort because there is an extra LI element in the list with absolute positioning (the one being dragged), and it throws off the even and odd selectors.</p> <p>The solution was to use the <code>change</code> callback that is invoked every time the DOM changes during sorting. You can then use jquery to accurately figure out which are the LI elements that are actually in the first column and apply <code>clear: both</code> to those elements.</p> <pre><code> function setClearsOnFirstColumn() { var colNum = 0; $(".myList").find( "li:not(.ui-sortable-helper)" ).each( function() { var thisLiEl = $(this); if( colNum == 0 ) thisLiEl.css( "clear", "both" ); else thisLiEl.css( "clear", "none" ); colNum ++; if( colNum == 2 ) colNum = 0; } ); } $(".myList").sortable( { change: setClearsOnFirstColumn, stop: setClearsOnFirstColumn } ); </code></pre> <p>The <code>not</code> part of the selector serves to ignore the LI element being dragged (identified by its <code>.ui-sortable-helper</code> class) when determining which are the LI elements in the first column. (Could also shorten this by using even and odd jquery selectors - it is not done that way here only because the snippet was adapted from a more general case to support more than two columns in the list.)</p> <p>Note you also need to call <code>setClearsOnFirstColumn</code> after the list is initially rendered.)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload