3 ms·
Searching for just the iPhone UA locks out other mobile WebKit-based browsers that may prefer an iPhone page, such as Android and the Pre. Even if you do want t
by rufo 17y ago
Searching for just the iPhone UA locks out other mobile WebKit-based browsers that may prefer an iPhone page, such as Android and the Pre. Even if you do want to serve just iPhone users, I think you'd be better off adding a new mime type and serving that.
Also, there's an onorientationchange event on the window object you can listen for, which would be much more efficient than firing a timer every 200ms.
This article (while a bit old) I think does a better job of showing you should go about writing an iPhone-friendly interface with Rails:
http://www.slashdotdash.net/2007/12/04/iphone-on-rails-creating-an-iphone-optimised-version-of-your-rails-site-using-iui-and-rails-2/ http://www.slashdotdash.net/2007/12/04/iphone-on-rails-creat...
- hopeless 17y agoThat article is no older than the one linked! There's also a rails plugin that can serve mobile views to various mobile browsers including opera mobile. Sorry, on mobile at the moment and I can't remember the name but try searching github.
- rufo 17y agoYou're right, it wasn't the newest example, but I didn't say it was newer - I mainly thought it was an example of better Rails design and development than the linked article. (Why should the controller be concerned at all with what orientation the phone is in? That's a client-side view concern, not the controller's... unless you're loading additional content, in which case you should load that content, not ping back to the server with a new width. I'm also not clear why you'd add an attribute to body for reformatting the page when you could just add a class.) I think this is the extension you're referring to - a cursory glance looks good to me: http://github.com/brendanlim/mobile-fu/tree/master http://github.com/brendanlim/mobile-fu/tree/master
- hopeless 17y agoMobile_fu. You're right! I used it briefly on a site before removing the functionality as I didn't really need it.