I have the following code: ---- <div id="order"> <ul> <% @orders.reverse.each do |order| %> <li><%= link_to_remote( "#{order.id} #{order.name}" , :url => {:controller => ''orders'', :action => ''show'', :id => order.id }, :update => "order_div", :method => ''get'' ) %></li> <% end %> </ul> </div> ---- I want to create a button or link to scroll these order items by 5 at a time. So it should display the first 5 by default. I will then be able to click a button below and it should scroll the next 5, hiding the previous. I know this is a tall order. I''ve been looking into a lot of slider plugins. None of them do what I want. Most of them only scroll content one item at a time. The closest thing I used was easySlider (jQuery). Cool plugin, but I didn''t know how to adapt it to scroll by 5 items at a time. Plus, it messed up my css formatting and the items went all wonky each time I clicked the button to scroll to the next item. I''m using (for now) jQuery, Prototype, and Script.aculo.us. I''m running different things from each JS library in separate parts of my app (to get a feel for what I want to use), so any help to do this kind of thing in any of these libraries will be much appreciated. I''m not stuck to one or the other. Thanks! -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Matt Royer wrote:> ---- > > <div id="order"> > > <ul> > > <% @orders.reverse.each do |order| %> > > <li><%= link_to_remote( "#{order.id} #{order.name}" , :url => > {:controller => ''orders'', :action => ''show'', :id => order.id }, :update > => "order_div", :method => ''get'' ) %></li> > > <% end %> > > </ul> > > </div> > > ---- > > I want to create a button or link to scroll these order items by 5 at a > time. So it should display the first 5 by default. I will then be able > to click a button below and it should scroll the next 5, hiding the > previous.Nevermind. I know I should post this at one of the JS framework forums. Only posted here to see if there is any way to take care of the Rails side of things to cut down on the JS work. -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Michael Pavling
2010-Jun-01 20:49 UTC
Re: Re: Only display 5 items at a time with more button
On 1 June 2010 21:32, Matt Royer <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Matt Royer wrote: >> <% @orders.reverse.each do |order| %>First off; rather than reversing the @orders; why don''t you have the finder that populates it order how you want? Seems like an extra, redundant step to me.> Nevermind. I know I should post this at one of the JS framework forums. > Only posted here to see if there is any way to take care of the Rails > side of things to cut down on the JS work.Then for your scrolling; you could use the commonly-used Will Paginate to return "pages" of five orders at a time. How you render the pages (with funky JS fading, etc) is your concern; but it''s not uncommon to use RJS (or your own JS) to replace the content of a div with the return from a controller. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Michael Pavling wrote:> First off; rather than reversing the @orders; why don''t you have the > finder that populates it order how you want? Seems like an extra, > redundant step to me.Thank you very much for the tip! I''m still getting the hang of Rails and Ruby. It was a way that worked quickly for me, but your way makes a lot more sense.> Then for your scrolling; you could use the commonly-used Will Paginate > to return "pages" of five orders at a time. How you render the pages > (with funky JS fading, etc) is your concern; but it''s not uncommon to > use RJS (or your own JS) to replace the content of a div with the > return from a controller.Perfect! Thank you very much. I''ve been working on this problem forever. Honestly had no idea how to achieve that functionality. I mainly wanted 5 items at a time. Didn''t really care how I got there (thought JS would be the quickest, that''s why I posted this), so thank you very much for the solution! -- Matt Royer -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Matenia Rossides
2010-Jun-02 00:35 UTC
Re: Only display 5 items at a time with more button
there is a function called in_groups_of .. there is a railscast episode about it. I have used a manual scrolling slider similar to what you want at the bottom of http://www.conikitv.com/ where it will grab the first hundred videos and display them in groups of 10 using the slider. Basically the thinking is - Fetch the items you want to show - display them in groups of 10 render how each group is displayed - render the container for each group I hope this helps. Links: http://railscasts.com/episodes/28-in-groups-of : http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Array/Grouping.html#M001216 -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Matenia Rossides wrote:> there is a function called in_groups_of .. there is a railscast > episode about it. > I have used a manual scrolling slider similar to what you want at the > bottom of http://www.conikitv.com/ where it will grab the first > hundred videos and display them in groups of 10 using the slider. > > Basically the thinking is > - Fetch the items you want to show > - display them in groups of 10 > render how each group is displayed > - render the container for each groupFor efficiencies sake you shouldn''t fetch all the items up-front. The user may never scroll/page past the first couple of groups. Better to use will_paginate to fetch the additional groups. -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.