title: How do I connect multiple sortable lists to each other in jQuery UI?
body: <p>I'm new to jQuery, and I'm totally struggling with using jQuery UI's <code>sortable</code>.</p>
  
  <p>I'm trying to put together a page to facilitate grouping and ordering of items.</p>
  
  <p>My page has a list of groups, and each group contains a list of items. I want to allow users to be able to do the following:  </p>
  
  <blockquote>
    <ol>
    <li>Reorder the groups  </li>
    <li>Reorder the items within the groups  </li>
    <li>Move the items between the groups</li>
    </ol>
  </blockquote>
  
  <p>The first two requirements are no problem. I'm able to sort them just fine. The problem comes in with the third requirement. I just can't connect those lists to each other. Some code might help. Here's the markup.  </p>
  
  <pre><code>&lt;ul id="groupsList" class="groupsList"&gt;  
    &lt;li id="group1" class="group"&gt;Group 1  
      &lt;ul id="groupItems1" class="itemsList"&gt;  
        &lt;li id="item1-1" class="item"&gt;Item 1.1&lt;/li&gt;  
        &lt;li id="item1-2" class="item"&gt;Item 1.2&lt;/li&gt;  
      &lt;/ul&gt;  
    &lt;/li&gt;
    &lt;li id="group2" class="group"&gt;Group 2  
      &lt;ul id="groupItems2" class="itemsList"&gt;  
        &lt;li id="item2-1" class="item"&gt;Item 2.1&lt;/li&gt;  
        &lt;li id="item2-2" class="item"&gt;Item 2.2&lt;/li&gt;  
      &lt;/ul&gt;  
    &lt;/li&gt;
    &lt;li id="group3" class="group"&gt;Group 3  
      &lt;ul id="groupItems3" class="itemsList"&gt;  
        &lt;li id="item3-1" class="item"&gt;Item 3.1&lt;/li&gt;  
        &lt;li id="item3-2" class="item"&gt;Item 3.2&lt;/li&gt;  
      &lt;/ul&gt;  
    &lt;/li&gt;
  &lt;/ul&gt;  
  </code></pre>
  
  <p>I was able to sort the lists by putting <code>$('#groupsList').sortable({});</code> and <code>$('.itemsList').sortable({});</code> in the <code>document ready function</code>. I tried using the <code>connectWith</code> option for <code>sortable</code> to make it work, but I failed spectacularly. What I'd like to do is have the every <code>groupItemsX</code> list connected to every <code>groupItemsX</code> list but itself. How should I do that?</p>
  
  <hr>
  
  <p>I was thinking I needed to specifically not connect a list to itself less there be some sort of circular reference. Granted, I'm not working with Excel, but it seemed like that could cause some sort of never ending recursion that would cause a stack overflow or something. Hmm. Sorry for the pun. Couldn't help myself.  </p>
  
  <p>Anyway, I was trying to do something like this, and it wasn't working:  </p>
  
  <pre><code>$('.groupsList').sortable(); // worked great  
  $('.groupsList').each( function () {  
      $(this).sortable( {  
          connectWith: ['.groupsList':not('#'+ $(this).attr('id') )];  
      });  
  });  
  </code></pre>
  
  <p>I'm sure I've completely mangled the syntax there, and I suppose that's the reason I had to ask the question in the first place. Is it even necessary or helpful performance-wise to filter the current item out of the list?</p>
  
  <p>Both of the answers provided by Adam and JimmyP worked in IE (although they behave really oddly in FireFox, overwriting list items when you try to re-sort). I'll accept one of your answers and vote on the other, but if you have ideas/ suggestions about the filtering, I'd like to hear it.</p>