does not remain on same page by device orientation change

does not remain on same page by device orientation change

I have a jquery mobile app integrated with phonegap to deploy on android devices, with following markup in index.html file :

  1. <head>
        <meta charset="utf-8">
        <title>jQuery Mobile 1.3.0</title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="jquery.mobile-1.3.0.min.css" />
    	<link rel="stylesheet" href="app.css"/>
    	
    	<script src="js/cordova.js"></script>
    	<script type="text/javascript" src="js/cordova-plugins.js"></script>
    	
        <script src="js/jquery.js"></script>
    	
        <script src="js/rtl.jquery.mobile-1.3.0.min.js"></script>
    	
    	<script src="js/app.js"></script>
    	
    </head>
    <body>
        <div data-role="page" id="home">
    		<div data-role="header" data-theme="c">
    		    
    			<a href="#aboutus"  data-icon="info" data-position="left" data-iconpos="notext"></a>
    		</div>
    		<div data-role="content" id="homecontent">
    		    
    			 <a href="details.html?id=1">Details</a>
    </div> </div> <div data-role="page" id="aboutus"> <div data-role="header" data-theme="c"> <a href="#home" data-icon="home" data-iconpos="notext"></a> </div> <div data-role="content"> </div> </div> <script> </script> </body> </html>

When I go to about page and change the device orientation, it redriect to 'home' page and does not remian on the current page.

also in home page 'pagecreate' event I check a condition and if it true, I change the page to about page, but I see that home page`s 'pagebeforeshow' event is fired, and I dont want it to happen.


  1. $(document).on('mobileinit',null, function (e) {
  2. if (e) { e.preventDefault(); }
  3. $.support.cors = true;
  4. $.mobile.pushStateEnabled = false;
  5. });
  6. $(document).on('pagecreate', '#home', function (e) {
  7.             if (e) { e.preventDefault(); }

  8.                 if(condition)
  9.                 {

  10.                         $.mobile.changePage( "#aboutus",null );
  11.                 }
  12.                 else
  13.                 {
  14.                     //
  15.                 }

  16.     });

  17. $(document).on('pagebeforeshow', '#home', function (e) {
  18.         if (e) { e.preventDefault(); }

  19. });
I use  jQuery Mobile 1.3.0 and jQuery v1.9.1
and cordova version is  2.9.0