I have a Rails 3 inhouse application which is used on:
19″ touch screen, 10″ iPads, 7″ Tablet
I am using will_paginate / kaminari for displaying lists of data.
But how can I configure how many items per page it should display depending on the screen size?
e.g. 20 lines for a 19″ display, 11 lines for a 10″ display, 8 lines for a 7″ display
You might consider on the first request to your application passing via Ajax the relevant
navigatorand/orscreeninformation and using that information to decide on the backend in Rails.To get browser/OS information, see Javascript’s
navigatorobject and to get information about the screen dimensions, check Javascript’sscreenobject.Your Ajax controller action could store JSON versions of the navigator/screen information to
sessionand abefore_filterinApplicationControllercould be used to set@per_pagefor use throughout your application’s paginators.You’d then pass
@per_pageto kaminari’s pager.