title: JQuery sortable lists connectWith serialize?
body: <p>I followed Railscast about sortable lists and it worked perfectly for one sortable list. But when I tried to create two connected sortable lists I've discovered that serialize can store only ids of elements. Is there a way to make serialize store also list's id for each list element id? Or merge list's element parent id into serialize result accordingly?</p>
  
  <p>This answer <a href="https://stackoverflow.com/questions/13204628/jquery-ui-sortable-connected-lists-save-order-and-association-to-rails-model">jQuery-UI Sortable Connected-Lists save order and association to rails model</a> is quite close to what I am looking, following this I've managed to drag elements between lists and successfully save it to db, but sorting elements withing one list doesn't save properly.</p>
  
  <p>View</p>
  
  <pre><code>&lt;% @project.tasks.group_by(&amp;:column).each do |column, tasks| %&gt;
      &lt;ul id='tasks_&lt;%= column %&gt;' data-update-url='&lt;%= sort_project_tasks_url(@project) %&gt;'&gt;
      &lt;% tasks.sort_by! { |t| t.priority }.each do |task| %&gt;
          &lt;li id="task_&lt;%= task.id %&gt;"&gt;
          &lt;%= task.name %&gt;| &lt;%= column %&gt; | &lt;b&gt;&lt;%= task.priority %&gt;&lt;/b&gt;
          &lt;/li&gt;
      &lt;% end %&gt;
      &lt;/ul&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>The script plain serialization variant I've used.</p>
  
  <pre><code>jQuery -&gt;
      $('#tasks_done').sortable
      connectWith: '#tasks_dev'
      update: -&gt;
          $.post($(this).data('update-url'), $(this).sortable('serialize'))
  </code></pre>
  
  <p>Script I've got from linked question. It also works fine for dragging elements between lists, but sorting within list won't save properly</p>
  
  <pre><code>jQuery -&gt;
      $('#tasks_dev').sortable
      connectWith: '#tasks_done'
      update: (event, ui) -&gt;
          neworder = new Array()
          $(this).children().each -&gt;
              column = $(this).parent().attr('id')
              id = $(this).attr('id').match(/((?!task_).)*$/)[1]
          neworder.push(
              id: id
          column: column
          )
      $.post($(this).data('update-url'), Activity: JSON.stringify(neworder))
  </code></pre>
  
  <p>Corresponding action in controller (without strong params for now), updated for second script variant</p>
  
  <pre><code>def sort
       JSON.parse(params[:Activity]).each_with_index do |data, index|
       id = data['id']
       priority = index + 1
       column = data['column']
       column.slice! 'tasks_' # columns ids are tasks_&lt;%= task.column %&gt;
       task = Task.find(id)
       task.update_attributes(priority: priority, column: column)
  end
  </code></pre>
  
  <p>So, the main problem is: I can't figure out how to save sort result within one list while keeping track of elements moved between lists. It seems easy to do on server side, but I'm inexperienced with front-end and can't figure out how to form params on client properly.</p>