title: Swapping two jQuery draggable list items not working properly (with jsFiddle example)
body: <p>The minimalist working example below swaps the two boxes when box 'one' is dragged and dropped on box 'two'. The problem is that when box 'one' is dropped, its style has 'top' &amp; 'left' values causing it to be placed away from where it should drop. Its class includes 'ui-draggable-dragging'. It seems the top &amp; left values are related to the amount the elements were dragged before the drop. And the dragging  was 'interrupted' hence the residual 'ui-draggable-dragging' class?</p>
  
  <p>What am I missing to make the swap work seamlessly? <a href="http://jsfiddle.net/KPNvw/" rel="nofollow">full jsfiddle example here</a></p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  
      &lt;script type="text/javascript" src="includes/jquery-1.4.2.min.js"&gt;&lt;/script&gt;
  
      &lt;script type="text/javascript" src="includes/jquery-ui-1.8.2.custom.min.js"&gt;&lt;/script&gt;
  
      &lt;script type="text/javascript"&gt;
  
          jQuery.fn.swapWith = function(to) {
              return this.each(function() {
                  var copy_to = $(to).clone(true);
                  var copy_from = $(this).clone(true);
                  $(to).replaceWith(copy_from);
                  $(this).replaceWith(copy_to);
              });
          };
  
          $(document).ready(function() {
  
          options = {revert: true};
  
          $("li").draggable(options)
          $('#wrapper').droppable({
              drop: function(event, ui) {
              $(ui.draggable).swapWith($('#two'));
              }
          });
          });
      &lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form&gt;
      &lt;ul id="wrapper"&gt;
          &lt;li id='one'&gt;
              &lt;div style="width: 100px; height: 100px; border: 1px solid green"&gt;
                  one&lt;br /&gt;&lt;/div&gt;
          &lt;/li&gt;
          &lt;li id='two'&gt;
              &lt;div style="width: 110px; height: 110px; border: 1px solid red"&gt;
                  two&lt;br /&gt;&lt;/div&gt;
          &lt;/li&gt;
      &lt;/ul&gt;
      &lt;br /&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>