ruby on rails - Rendering different partials depending on user window size -


i test if user's browser window.width >= 800px if render partial otherwise if window.width >= 800px.

i have little experience, please explain options on implementation: expecting either javascript method on page or jquery.

i have tried

http://scottwb.com/blog/2012/02/23/a-better-way-to-add-mobile-pages-to-a-rails-site/

but 1. doesn't work me. 2. if did expect work based on device being used, not pixel count.

thank in advance!

a request won't contain data screen size, in common sense sever has no way know screen width , response serve, pinnym mentioned in comment.

a general practice use user agent detect mobile device server. user agent part of request. it's not 100% accurate, it's still depend on cases.

however, there still solutions question - serve page based on screen size.

the workaround use javascript detect screen size @ first, use js drop cookie. server able read cookie , decide template render.

the basic repo here: https://github.com/mattstauffer/simple-ress it's php, can idea source code.

there rails implementation: https://github.com/matthewrobertson/ress, , introduction: http://matthewrobertson.org/blog/2013/02/15/introducing-ress/

my opinion: don't solution though viable. lots of works , lots of things taking care of. rather user user agent detect instead.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -