2

I am alerting a message on orientationchange.

$(window).bind("orientationchange", function(e){

    alert('orientation change');
});

Also, if you notice the class names on the body tag, the portrait/landscape class name never changes like it does in the JQM demos -- it just stays at whatever it was when you loaded the page. Any help debugging this unusual problem is greatly appreciated.

EDIT Sorry i forgot to leave a link to my project :/

http://www.foodtrucksmap.com/m/la

D-Nice
  • 4,772
  • 14
  • 52
  • 86
  • its working for me http://jsfiddle.net/f8h3p/64/ – Rafay Aug 18 '11 at 06:51
  • Which device are you using? In Android there is a device setting "auto rotation", which has to be enabled. – Christoph Baudson Aug 18 '11 at 06:53
  • I know that it works in JQM, it just doesn't work in my app (sorry, i forgot to leave this link in the OP. it has been edited). I'm using a droid x, but it isn't being fired on iOS, nor when i try to resize the browser on my desktop. the JQM demo works perfectly in all the aforementioned cases, but none of them work in my app. – D-Nice Aug 18 '11 at 18:25

1 Answers1

3

// Get the current page orientation. This method is exposed publicly, should it
// be needed, as jQuery.event.special.orientationchange.orientation()

Try:

$(window).bind( 'orientationchange', function(e){
    alert(jQuery.event.special.orientationchange.orientation());
});
Phill Pafford
  • 83,471
  • 91
  • 263
  • 383
  • 1
    I'll keep that in mind because I've read about the issues where the current orientation is slow to update. My problem, however, is that the orientation change event will never be fired in the first place, so that alert will never be reached. My bad, i forgot to include a link to my project in the OP. Edited. – D-Nice Aug 18 '11 at 18:27
  • testing the URL: http://www.foodtrucksmap.com/m/la on iPhone 4 iOS 4.3.3 I get the orientation changed alert but you app also crashes the browser – Phill Pafford Aug 18 '11 at 19:07
  • Wow, you are right -- just tested on my iPod touch. That's interesting, i had never seen it crash the browser before. I think that's only happening in Los Angeles (around lunch time) because there are so many food trucks open. i need to cluster the markers, but thats another problem. If you try the san francisco link, http://www.foodtrucksmap.com/sf it seems to work fine – D-Nice Aug 18 '11 at 20:51
  • interesting though, now i do seem to be getting the orientation change event on my iPod touch and droid x. I will go back and look at my changes to see what it was causing the problem -- i think broken code was stored in my cache. I am noticing, however, that the orientation that is assigned when the event is fired is old, so i believe that the code you posted in this answer will be instrumental in fixing my woes. ill update this question tonight when i get a chance. – D-Nice Aug 18 '11 at 20:58
  • If you are not using jquery.mobile you can just check window.orientation for instance http://stackoverflow.com/a/11543932/706466 – Pawel Dubiel Jul 18 '12 at 14:41