Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I ran into the same problem, that the <code>items</code> option doesn't seem to remove items which had been previously enabled.</p> <p>The <code>cancel</code> option, however, does. Note that the disabled items will shift around to make room for the sortable ones (the spot is still available as a drop target), but dragging the disabled items themselves will not work. Using a <code>disabled</code> class also makes it easy to change the style based on whether or not the item is sortable (see on <a href="http://jsfiddle.net/Sxg8D/122/" rel="nofollow">jsfiddle</a>). </p> <p>The code here is partially based on Bah Bah the Lamb's answer, but it has been greatly tidied and simplified.</p> <p>The html:</p> <pre><code>&lt;ul id="sorted-list"&gt; &lt;li&gt; &lt;p&gt;&lt;input type="checkbox" checked="true" /&gt; Item 1&lt;/p&gt; &lt;/li&gt; &lt;li&gt; &lt;p class="disabled"&gt;&lt;input type="checkbox" /&gt; Item 2&lt;/p&gt; &lt;/li&gt; &lt;li&gt; &lt;p&gt;&lt;input type="checkbox" checked="true" /&gt; Item 3&lt;/p&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>The jQuery:</p> <pre><code>$("#sorted-list").sortable({ cancel:".disabled" }); // add or remove the 'disabled' class based on the value of the checkbox $("#sorted-list input").click(function() { if (this.checked) { $(this.parentElement).removeClass("disabled"); } else { $(this.parentElement).addClass("disabled"); } }); </code></pre> <p>The CSS:</p> <pre><code>li { border: 1px solid #aaa; background-color: #eee; color:#555; padding: 5px; } .disabled { color:#ddd; } </code></pre>
 

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