Forum: Ruby on Rails Sortable list with non ajax submission

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Matthew M. (Guest)
on 2006-06-10 02:33
(Received via mailing list)
I am trying to create a sortable list that is submitted not with an AJAX
call but by a standard form submit button.
Right now I have

def reorder_group_members
    @group = Group.find(params[:id])
    @group.group_members.each do |member|
      member.position = params[:memberlist].index(member.id.to_s) + 1
#I get a nil error for this line.  It would seem that
params[:memberlist] is not getting set.
      member.save
    end
    render :action => 'index'
end

with view

<%=start_form_tag  :action=>'reorder_group_members', :id => @group%>
  <ul class="group_members" id="memberlist"
style="height:150px;width:200px;">
  <% for member in @group.group_members-%>
    <li id="memberlist_<%=member.id%>"><%=member.name%></li>
  <%end%>
  </ul>
  <%=submit_tag%>
<%=end_form_tag%>
<%= sortable_element 'memberlist' -%>

This works fine in terms of the member list being sortable by dragging
but when I click the submit button I get a nil error because the sorting
information is not being passed as a paramater.  Any ideas?

Thank you,
Matthew M.
blog.mattmargolis.net
This topic is locked and can not be replied to.