Hi,
I''m new to the script.aculo.us library and AJAX. Of course, I already
want to use a sortable list for something more complicated than the
sortable list demo. In the example below, what is the structure of
params[:list]? I don''t know what I can do with it once I have it in my
controller method.
Thanks,
Peter
# view
<ul id="list">
<% 6.times do |i| -%>
<li id="item_<%= i+1 %>">I''m number <%= i+1
%></li>
<% end -%>
</ul>
<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''
end
# _list.rhtml partial
Updated order is: <%= @order.join('', '') %>.
It looks like params[:list] is an array of the numbers in the li id. Simple as that? Thanks, Peter
Hi, when you declare the id''s of the li elements like <li id="entity_2043"></li> <li id="entity_2560"></li> <li id="entity_2953"></li> then Sortable.serialize will return the part after the underscore in your id attribute in the order the are sorted as an array. Peter Michaux wrote:>It looks like params[:list] is an array of the numbers in the li id. >Simple as that? > >Thanks, >Peter >_______________________________________________ >Rails-spinoffs mailing list >Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > >