Using revert inside beforeStop() causes error - how to fix? <p>I have a nestedSortable list in which I'm disallowing the nesting of items with the same name (could be id, whatever). I'm using the beforeStop() method to get the name of the current element and the name of its parents parent (because when it's nested, it gets the form:)</p> <pre><code>&lt;ol class="sortable"&gt; &lt;li&gt;&lt;div id="1"&gt;Item&lt;/div&gt; &lt;ol&gt; &lt;li&gt; &lt;div id="2"&gt;Item&lt;/div&gt; &lt;/li&gt; &lt;/ol&gt; &lt;/li&gt; &lt;/ol&gt; </code></pre> <p>Notice that I'm using the div element as the handle. My code to initialize the nestedSortable is</p> <pre><code> $('ol.sortable').nestedSortable({ disableNesting: 'no-nest', forcePlaceholderSize: true, handle: 'div', helper: 'clone', items: 'li', maxLevels: 5, opacity: .6, placeholder: 'placeholder', revert: 250, tabSize: 25, tolerance: 'pointer', toleranceElement: '&gt; div', beforeStop: function(event, ui){ // disallows two elements with the same part number from nesting var thisName = ui.item[0].firstChild.innerHTML; var parentName = ui.item[0].parentElement.parentElement.firstChild.innerHTML; if (thisName == parentName){ $(this).sortable('cancel'); } } }); </code></pre> <p>This code does work to disallow nesting of items with the same name, and if I console log the moved element and its grandparent, I can see that I'm referencing the correct elements. However, I also get the following console error after calling sortable('cancel'), which naturally blows up IE:</p> <p>Uncaught TypeError: Cannot call method 'removeChild' of null </p> <pre><code>jquery-ui-1.8.12.custom.min.js </code></pre> <p>d.widget._clear </p> <pre><code>jquery-ui-1.8.12.custom.min.js:269 </code></pre> <p>$.widget.$.extend._clear</p> <pre><code> jquery.ui.nestedSortable.js:305 </code></pre> <p>d.widget._mouseStop </p> <pre><code>jquery-ui-1.8.12.custom.min.js:237 </code></pre> <p>f.extend.speed.d.complete </p> <pre><code>jquery.js:4 </code></pre> <p>f.fx.step</p> <pre><code>jquery.js:4 </code></pre> <p>h</p> <pre><code>jquery.js:4 </code></pre> <p>f.extend.tick </p> <pre><code>jquery.js:4 </code></pre> <p>Can someone give me some tips on how to debug this? Or is there an alternate way you would recommend? I'm using the latest version, 1.3.4, and jQuery 1.7.1.</p>