libsfan01
2007-Jun-11 11:04 UTC
extending the Rails Recipies sortable list example to include multiple lists
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'') %> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
libsfan01
2007-Jun-11 16:29 UTC
Re: extending the Rails Recipies sortable list example to include multiple lists
Doesn''t anyone know a tutorial for this? Marc On Jun 11, 12:04 pm, libsfan01 <mcyi2...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> 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'') > %>--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---