larryq
larryq

Reputation: 16299

Possible to learn a device's orientation in document.ready() event?

I'm retrieving a mobile device's orientation in the window.load event in jQuery. The problem, of course, is this event isn't fired until all images etc are loaded into the browser. Therefore my app's reaction time is slowed.

I'm retrieving the orientation in the load event by calling $.event.special.orientationchange.orientation(), which works great for both the load and orientationchange events. However, I don't see any event argument passed into document.ready(), so I can't seem to learn the device's orientation at that time.

Is it possible to do this, to figure out the device's orientation in document.ready()?

Upvotes: 0

Views: 169

Answers (1)

Pablo
Pablo

Reputation: 2854

Better use jQueryMobile event pageinit instead of document.ready(). See the reference in the documentation: http://jquerymobile.com/demos/1.2.0/docs/api/events.html

Upvotes: 2

Related Questions