Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Following will sort the elements after the drop.</p> <pre><code> $('#boxes_holder, #dragBox').sortable({ connectWith: '.initBox', //Whenever Dropped Item receive: function (event, ui) { $(this).find('div.boxes').sort(sortAlpha).appendTo(this); if ($(this).children().length &gt; 5) { if ($(this).attr('id') == 'dragBox') { $(ui.sender).sortable('cancel'); } } } }); function sortAlpha(a,b){ return a.innerHTML.toLowerCase() &gt; b.innerHTML.toLowerCase() ? 1 : -1; } </code></pre> <p>Check the unfiddle. <a href="http://jsfiddle.net/nsjithin/7yMSz/1/" rel="nofollow">http://jsfiddle.net/nsjithin/7yMSz/1/</a></p> <p>Edit : So it need to sorted whenever, the position changed, sorted or dragged/dropped. You need to put it in the <code>update</code> event handler.</p> <pre><code> $('#boxes_holder, #dragBox').sortable({ connectWith: '.initBox', update: function( event, ui ) { $(this).find('div.boxes').sort(sortAlpha).appendTo(this); }, //Whenever Dropped Item receive: function (event, ui) { if ($(this).children().length &gt; 4) { if ($(this).attr('id') == 'dragBox') { $(ui.sender).sortable('cancel'); } } } }); </code></pre> <p>Edit 2 : Working with the <code>&lt;li&gt;</code> html structure.</p> <pre><code>$('#boxes_holder, #dragBox').sortable({ connectWith: '.initBox', update: function( event, ui ) { $(this).find('li').sort(sortAlpha).appendTo(this); }, //Whenever Dropped Item receive: function (event, ui) { if ($(this).children().length &gt; 4) { if ($(this).attr('id') == 'dragBox') { $(ui.sender).sortable('cancel'); } } } }); function sortAlpha(a,b){ return a.innerHTML.toLowerCase() &gt; b.innerHTML.toLowerCase() ? 1 : -1; } </code></pre> <p>Jsfiddle : <a href="http://jsfiddle.net/nsjithin/7yMSz/3/" rel="nofollow">http://jsfiddle.net/nsjithin/7yMSz/3/</a></p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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