Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I reset a list item in a sortable jquery list instead of completely removing it?
    text
    copied!<p>I've got two lists that are connected via jQuery sortable. The lists are floating next to each other. The list items from the right list can be dragged to the left list, the list items from the left list are not drag-able.</p> <p>When I drag a list item from the right list to the left list, I have a check in place that checks if any of the new connected list items are originally from the right list or not, if this is the case, that list item gets deleted via the jQuery remove function.</p> <pre><code>stop: function (event, ui) { var nextItemclass = ui.item.next().attr("class"); var prevItemClass = ui.item.prev().attr("class"); if ((nextItemclass == "sortableRow") &amp;&amp; (ui.item.parent().hasClass('static'))) { ui.item.next().remove(); //in stead of Remove I want this item to reset to it's original UI } if ((prevItemClass == "sortableRow") &amp;&amp; (ui.item.parent().hasClass('static'))) { ui.item.prev().remove(); //in stead of Remove I want this item to reset to it's original UI } } </code></pre> <p>Now in stead of completely removing the list item, I wish to return it to it's original list, the list in the right that is.</p> <p>So I wish to change the code <code>ui.item.prev().remove();</code> to a code that resets the list item to it's original list. I've also commented this in my original code.</p> <p>Here is a fiddle with my complete code:</p> <p><a href="http://jsfiddle.net/Y2RJj/30/" rel="nofollow">http://jsfiddle.net/Y2RJj/30/</a></p> <p>You'll notice that if you drag two different sortable items below a non-sortable item, the one that was there first will be completely removed. I wish to change the code in such a way that the list item that was there first will be reset to it's original list in stead of completely removed.</p>
 

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