Hi all
I have a site design with 3 sortable lists on the same page. i want to
be able to drag my
- s if that makes sense. how can i
- <%= food_item.quantity %> units of <%= food_item.name %> <% end %>
change the example code to do this:
controller:
class GroceryListController < ApplicationController
layout “standard”
def show
@grocery_list = GroceryList.find(params[:id])
end
…
def sort
@grocery_list = GroceryList.find(params[:id])
@grocery_list.food_items.each do |food_item|
food_item.position = params[‘grocery-
list’].index(food_item.id.to_s) + 1
food_item.save
end
render :nothing => true
end
end
view:
<%= @grocery_list.person.name %>'s Grocery List
<%= @grocery_list.name %>
-
<% @grocery_list.food_items.each do |food_item| %>
<%= sortable_element ‘grocery-list’,
:url => { :action => “sort”, :id => @grocery_list },
:complete => visual_effect(:highlight, ‘grocery-list’)
%>