Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your right that if you add an empty <code>&lt;li&gt;&lt;/li&gt;</code> inside the Sortable object that it resolves the issue.</p> <p>I think that it is a viable solution, for whatever reason the Sortable object just needs a sort-able item in it when the sort-able is initialized. I believe the heart of the answer is this: <code>The sortable needs to know what kind of elements it is going to be sorting when initialized in order for the placeholder to work properly. Therefore if you are going to be sorting li elements, you should initialize the sorter with at least 1 li element in the Sortable object.</code> </p> <p>I believe this to be the case because I tried replacing the empty <code>&lt;li&gt;</code> with and empty <code>&lt;div&gt;</code> and that did not fix the problem.</p> <p>Your solution currently only has two minor issues. The empty <code>&lt;li&gt;</code> is still accounted for when dragging the draggable. You can see that the draggable can sort to the left and the right of the <code>empty li</code> which kinda looks funny. Also you can drag the <code>empty li</code> which can cause some confusion. </p> <p>But luckily the work around for this is really simple. The <code>li</code> just needs to be in the sortable when its initialized. We can remove it after and everything works great!</p> <p>HTML - sortable with <code>li</code> element.</p> <pre><code>&lt;ul id="mylist"&gt; &lt;li&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>jQuery</p> <pre><code>$(function () { $("#myproducts li").draggable({ /*appendTo: "body",*/ helper: "clone", connectToSortable: "#mylist", tolerance: "pointer" }); $("#mylist").sortable({ placeholder: "sortable-placeholder" }); $("#mylist").empty(); //remove the empty li - only needed for initialization }); </code></pre> <p><a href="http://jsfiddle.net/X3Vmc/4/" rel="noreferrer">FIDDLE</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. 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