sortable_element

ul/li に使うもんだと思ってたけど、table/tbody にできるんじゃないかと思ってやってみたらできた。IEだとどうなるかはわからない。

<table id="user_profile_items" class="bordered" style="margin: 1em;width: 90%">
  <% @items.each do |item| %>
  <tbody id="<%= "user_profile_item_#{item.id}" %>" style="cursor: move;">
    <tr class="<%= cycle("even", "odd") %>">
      <%= render :partial => "show", :locals => {:item => item} %>
    </tr>
  </tbody>
  <% end -%>
</table>

<%= sortable_element 'user_profile_items',
    :url => orders_system_user_profile_items_path(),
    :tag => "tbody",
    :success => visual_effect(:highlight, 'user_profile_items') %>

というか、<tbody>は<tbody><tr>...</tr><tr>...</tr></tbody>?と思ってXHTML 1.0のスキーマみたらmaxOccurs="unbounded"だった罠。

いままでわざわざup/downボタンを用意していたのがなさけない。