popup on page2 navigates back to page1 after close

popup on page2 navigates back to page1 after close

This issue occurs on all browsers (including mobile ... tested on my Gingerbread 2.3.7 and ICS), except IE.  I click a button to change from page 1 to page 2 and then click another button that shows a popup, but when that message is closed it goes back to page 1.  I click the button on page 1 again so it goes to page 2, but then the popup button doesnt work.

page1.html
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.   <title>aWe</title>
  5.   <meta name="viewport" content="width=device-width, initial-scale=1" />

  6.   <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0-rc.1/jquery.mobile-1.2.0-rc.1.min.css" />
  7.   <script src="http://code.jquery.com/jquery-1.8.1.min.js" type="text/javascript"></script>
  8.   <script src="http://code.jquery.com/mobile/1.2.0-rc.1/jquery.mobile-1.2.0-rc.1.min.js" type="text/javascript"></script>
  9.   <script type="text/javascript">
  10.       function showMessage(HTMLMessage) {
  11.         var aPage = $.mobile.activePage.attr('id');
  12.         $('#' + aPage + ' .popupMsg h1').html('Message');
  13.         $('#' + aPage + ' .popupMsg p').html(HTMLMessage);
  14.         $('#' + aPage + ' .popupMsg').popup('open', { transition: 'slideup', reload: false });
  15.       }
  16.   </script>
  17. </head>
  18. <body class="ui-mobile-viewport">
  19.   <div data-role="page" id="page1">
  20.     <div data-role="header" data-theme="c" data-position="fixed">
  21.       <h1>Page 1</h1>
  22.     </div>
  23.     <div data-role="content">
  24.         <input type="submit" id="btnChangePage" data-theme="b" data-icon="home" data-iconpos="right" value="Change Page" data-mini="false" />
  25.     </div>
  26.     <div class="popupMsg" data-role="popup" data-overlay-theme="a">
  27.    <div data-role="header" data-theme="d" class="ui-corner-top" role="banner">
  28.    <h1 role="heading"></h1>
  29.    </div>
  30.    <div data-role="content" data-theme="c" class="ui-corner-bottom ui-content" role="main">
  31.    <p></p> 
  32.    </div>
  33.     </div>
  34.     <script type="text/javascript">
  35.         $('#page1').on('pageinit', function (event) {
  36.             $('#btnChangePage').click(function () {
  37.                 $.mobile.changePage('page2.html',
  38.                   { reloadPage: true, transition: 'slidedown', reverse: false, changeHash: false }
  39.                 );
  40.             });
  41.         });
  42.     </script>
  43.   </div>
  44. </body>
  45. </html>

page2.html
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.   <title>aWe</title>
  5.   <meta name="viewport" content="width=device-width, initial-scale=1" />

  6.   <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0-rc.1/jquery.mobile-1.2.0-rc.1.min.css" />
  7.   <script src="http://code.jquery.com/jquery-1.8.1.min.js" type="text/javascript"></script>
  8.   <script src="http://code.jquery.com/mobile/1.2.0-rc.1/jquery.mobile-1.2.0-rc.1.min.js" type="text/javascript"></script>
  9. </head>
  10. <body class="ui-mobile-viewport">
  11.   <div data-role="page" id="page2">
  12.     <div data-role="header" data-theme="c" data-position="fixed">
  13.       <h1>Page 2</h1>
  14.     </div>
  15.     <div data-role="content">
  16.         <input type="submit" id="btnShowMessage" data-theme="b" data-icon="home" data-iconpos="right" value="Show Message" data-mini="false" />
  17.     </div>
  18.     <div class="popupMsg" data-role="popup" data-overlay-theme="a">
  19.    <div data-role="header" data-theme="d" class="ui-corner-top" role="banner">
  20.    <h1 role="heading"></h1>
  21.    </div>
  22.    <div data-role="content" data-theme="c" class="ui-corner-bottom ui-content" role="main">
  23.    <p></p> 
  24.    </div>
  25.     </div>
  26.     <script type="text/javascript">
  27.         $('#page2').on('pageinit', function (event) {
  28.             $('#btnShowMessage').click(function () {
  29.                 showMessage('After this popup is closed you will be forced back to page1.html');
  30.             });
  31.         });
  32.     </script>
  33.   </div>
  34. </body>
  35. </html>

I am new to jQuery mobile, so if I am missing something simple here let me know.  Also feel free to criticize how I have my code written.

Hope someone can provide some assistance.