RVRoadie
2010-Mar-26 18:30 UTC
How to calculate per_page value based on browser window size for will_paginate
def self.per_page 20 end Any suggestion on how I can calculate this value base on the size of the browser window? Thanks -- 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.
E. Litwin
2010-Mar-26 18:55 UTC
Re: How to calculate per_page value based on browser window size for will_paginate
Why not allow the user to choose this value (i.e. via a drop down menu )? If you go that route, don''t forget to store this preference somewhere so your users don''t have to set it every time. (I''m looking at you Blockbuster.com) Eric -- 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.
RVRoadie
2010-Mar-26 22:52 UTC
Re: How to calculate per_page value based on browser window size for will_paginate
Ok, I tried as you suggested with: <%= select_tag(:per_page, options_for_select(%w{10 20 30 40 50}, selected = session[:per_page]), :onchange => "session[:per_page] this.value") %> Lines per page I can''t seem to get the :onchange to set a new value for session[:per_page]. I checked :onchange with an alert(this.value) and it did what I expected. Can you proved a sample of what I should be doing in :onchange Thanks. -- 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.
E. Litwin
2010-Mar-26 23:05 UTC
Re: How to calculate per_page value based on browser window size for will_paginate
> Can you proved a sample of what I should be doing in :onchangeI''ve used an "Apply" button inside of form_tag, which sends params back to the controller and I set the session there. If you wanted to use the :onchange event instead of requiring the user to click on a button, you would probably have to send an XMLHttpRequest to the server and then refresh the page with the new paginated data. Eric -- 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.
RVRoadie
2010-Mar-27 04:48 UTC
Re: How to calculate per_page value based on browser window size for will_paginate
Thanks for your ideas. I decided to make per_page an attribute of the user and set it at login. That way it gives all my list pages a common look. I had already put this inside a form_tag I am using for a search box, so I didn''t want to add another form_tag. The search box and the pagination boxes took up enough room on the page. Can you direct two different form_tags to appear on the same line? I still don''t get what I would put in the :onchange option. Can you give me an example? -- 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.