Forum: Ruby on Rails how to update ranking in sortable elements?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
997433f165140d58f52b8c0d1d005dc1?d=identicon&s=25 Patrick Aljord (Guest)
on 2006-12-29 13:35
(Received via mailing list)
hey all,
I have a sortable list like that:
# view
<ul id="list">
  <% 6.times do |i| -%>
<span class="item_position" id="item_position_<%= i+1 %>">
            <%= i+1 %></span>  <li id="item_<%= i+1 %>">I'm number <%=
i+1 %></li>
  <% end -%>

<p id="list-info"></p>

<%= sortable_element 'list',
      :update => 'list-info',
      :complete => visual_effect(:highlight, 'list'),
      :url => { :action => "order" } %>

# controller
def order
    @order = params[:list]
    render :partial => 'list'

I would like to update the position number in the span item_position
as I drag and drop elements. As an exemple, if I drag element number 5
to the second position I would like to update its span to 2.

Any idea how to do that?

thanx in advance

This topic is locked and can not be replied to.