Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>jQuery Mobile: Open and Close Dialog Box Programmatically</title>
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
- <script src="http://code.jquery.com/jquery-2.1.3.js"></script>
- <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.js"></script>
- <script type="text/javascript">
- $(document).bind("pageinit", function() {
- $('#openDialog').bind("tap", function() {
- $.mobile.changePage("#page2", {
- role: "dialog" // show #page2 as dialog
- })
- })
- $('#closeDialog').bind("tap", function() {
- $('#page2').dialog("close") // close #page2
- })
- $('#okButton').bind("tap", function() {
- $.mobile.changePage("#page3") // go to #page3
- })
- });
- </script>
- </head>
- <body>
- <div id="page1" data-role="page">
- <div data-role="header">
- <h1>Jacqui's Shop</h1>
- </div>
- <div data-role="content">
- <button id="openDialog">Show the dialog</button>
- </div>
- </div>
- <!-- dialog #page2 -->
- <div id="page2" data-role="page">
- <div data-role="header">
- <h1>jQuery Mobile Tutorials</h1>
- </div>
- <div data-role="content">
- This is the content area of the dialog
- <button id="okButton">OK</button>
- <button id="closeDialog">Close</button>
- </div>
- </div>
- <!-- dialog #page3-->
- <div id="page3" data-role="page">
- <div data-role="header">
- <h1>jQuery Mobile</h1>
- </div>
- <div data-role="content">
- Welocome to jQuery Mobile Tutorials -- You came here via the Dialog Box
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement