jQuery Mobile $(window).bind for different pages.
I would like to have two or more pages that display differently when the orientation of the device changes. At first I tried using
- $("#mapPage").bind('orientationchange', oriChange);
That didn't fire an event and so I wound up using this:
- $(window).bind("pageshow orientationchange resize", function(){
- if ($("#mapPage").is(".ui-page-active")) {
- oriChange();
- }
- });
- $(window).bind("pageshow orientationchange", function(){
- if ($("#profilePage").is(".ui-page-active")) {
- $("#chart").html("");
- $mt.getProfile();
- }
- });
This does what I want it to but I was wondering if there is a better way of achieving this result. It just seems to me that binding the window twice is not good practice.