Sortable list with non ajax submission


#1

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%>

    <% for member in @group.group_members-%>
  • <%=member.name%>
  • <%end%>
<%=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