How to Fire a jQuery Event on iPad/iPhone Rotate?

331 views
Skip to first unread message

Toby Cryns

unread,
Feb 22, 2013, 12:02:50 PM2/22/13
to mpls-stpau...@googlegroups.com
I am trying to fire a jQuery script when a user rotates her iPad or iPhone.

My code outline follows:

jQuery(document).ready(function($) {

//RUN FUNCTION HERE

// Run the script again any time the iPad or iPhone is rotated
$(window).bind('orientationchange', function(event) {
//RUN THE FUNCTION WHEN IPHONE/IPAD IS ROTATED
});
});

Am I missing something in the above code?

Thanks!
Toby

Nick Pelton

unread,
Feb 22, 2013, 12:07:41 PM2/22/13
to mpls-stpau...@googlegroups.com
I've heard people complain about unreliable events for orientation change. You can use a simple resize check and that would accomplish the same thing.

// jQuery required
 $j(window).resize(function(){ // catch resize event
// Do something
 });

Thanks,

Nick Pelton // Web Developer
contact | @nickpelton

--
You received this message because you are subscribed to the Google Groups "Minneapolis St. Paul WordPress User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mpls-stpaul-word...@googlegroups.com.
To post to this group, send email to mpls-stpau...@googlegroups.com.
Visit this group at http://groups.google.com/group/mpls-stpaul-wordpress?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages