Hi all
I have a site design with 3 sortable lists on the same page. i want to be able to drag my <li>s between <ul>s if that makes sense. how can i 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:
<h2><%= @grocery_list.person.name %>'s Grocery List</h2> <h3><%= @grocery_list.name %></h3>
<ul id="grocery-list"> <% @grocery_list.food_items.each do |food_item| %> <li id="item_<%= food_item.id %>" style='color:'> <%= food_item.quantity %> units of <%= food_item.name %> </li> <% end %> </ul>
</div>
<%= sortable_element 'grocery-list', :url => { :action => "sort", :id => @grocery_list }, :complete => visual_effect(:highlight, 'grocery-list') %>