Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rendering different partials depending on user window size

I would like to test if the user's browser window.width is >= 800px if so i would like to render partial A otherwise if window.width >= 800px.

I have little experience, please explain my options on implementation: I am expecting either a javascript method on the 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. it doesn't work for me. 2. even if it did I expect it will work based on device being used, not pixel count.

Thank you in advance!

like image 299
Sherwyn Goh Avatar asked Oct 22 '22 09:10

Sherwyn Goh


1 Answers

You could use Ahoy. The current_visit method contains the following information.

When someone visits your website, Ahoy creates a visit with lots of useful information.

traffic source - referrer, referring domain, landing page, search
keyword location - country, region, and city
technology - browser, OS, and device type
utm parameters - source, medium, term, content, campaign

like image 144
kartikluke Avatar answered Nov 03 '22 17:11

kartikluke