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
- <!DOCTYPE html>
- <html>
- <head>
- <title>aWe</title>
- <meta name="viewport" content="width=device-width, initial-scale=1" />
- <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0-rc.1/jquery.mobile-1.2.0-rc.1.min.css" />
- <script src="http://code.jquery.com/jquery-1.8.1.min.js" type="text/javascript"></script>
- <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>
- <script type="text/javascript">
- function showMessage(HTMLMessage) {
- var aPage = $.mobile.activePage.attr('id');
- $('#' + aPage + ' .popupMsg h1').html('Message');
- $('#' + aPage + ' .popupMsg p').html(HTMLMessage);
- $('#' + aPage + ' .popupMsg').popup('open', { transition: 'slideup', reload: false });
- }
- </script>
- </head>
- <body class="ui-mobile-viewport">
- <div data-role="page" id="page1">
- <div data-role="header" data-theme="c" data-position="fixed">
- <h1>Page 1</h1>
- </div>
- <div data-role="content">
- <input type="submit" id="btnChangePage" data-theme="b" data-icon="home" data-iconpos="right" value="Change Page" data-mini="false" />
- </div>
- <div class="popupMsg" data-role="popup" data-overlay-theme="a">
- <div data-role="header" data-theme="d" class="ui-corner-top" role="banner">
- <h1 role="heading"></h1>
- </div>
- <div data-role="content" data-theme="c" class="ui-corner-bottom ui-content" role="main">
- <p></p>
- </div>
- </div>
- <script type="text/javascript">
- $('#page1').on('pageinit', function (event) {
- $('#btnChangePage').click(function () {
- $.mobile.changePage('page2.html',
- { reloadPage: true, transition: 'slidedown', reverse: false, changeHash: false }
- );
- });
- });
- </script>
- </div>
- </body>
- </html>
page2.html
- <!DOCTYPE html>
- <html>
- <head>
- <title>aWe</title>
- <meta name="viewport" content="width=device-width, initial-scale=1" />
- <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0-rc.1/jquery.mobile-1.2.0-rc.1.min.css" />
- <script src="http://code.jquery.com/jquery-1.8.1.min.js" type="text/javascript"></script>
- <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>
- </head>
- <body class="ui-mobile-viewport">
- <div data-role="page" id="page2">
- <div data-role="header" data-theme="c" data-position="fixed">
- <h1>Page 2</h1>
- </div>
- <div data-role="content">
- <input type="submit" id="btnShowMessage" data-theme="b" data-icon="home" data-iconpos="right" value="Show Message" data-mini="false" />
- </div>
- <div class="popupMsg" data-role="popup" data-overlay-theme="a">
- <div data-role="header" data-theme="d" class="ui-corner-top" role="banner">
- <h1 role="heading"></h1>
- </div>
- <div data-role="content" data-theme="c" class="ui-corner-bottom ui-content" role="main">
- <p></p>
- </div>
- </div>
- <script type="text/javascript">
- $('#page2').on('pageinit', function (event) {
- $('#btnShowMessage').click(function () {
- showMessage('After this popup is closed you will be forced back to page1.html');
- });
- });
- </script>
- </div>
- </body>
- </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.