JQuery Mobile 2 Page BoilerPlate


/ Published in: jQuery
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <!DOCTYPE html>
  2. <html>
  3.  
  4. <head>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7.  
  8. <title>Multi-page template</title>
  9.  
  10. <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0rc1/jquery.mobile-1.0rc1.min.css" />
  11. <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
  12. <script src="http://code.jquery.com/mobile/1.0rc1/jquery.mobile-1.0rc1.min.js"></script>
  13. </head>
  14.  
  15.  
  16.  
  17. <body>
  18.  
  19. <!-- Start of first page: #one -->
  20. <div data-role="page" id="foo" data-title="Page Foo">
  21.  
  22. <div data-role="header">
  23. <h1>Multi-page</h1>
  24. </div><!-- /header -->
  25.  
  26. <div data-role="content" id="one">
  27. <h2>One</h2>
  28.  
  29. <p>I have an id of "one" on my page container. I'm first in the source order so I'm shown when the page loads.</p>
  30.  
  31. <p>This is a multi-page boilerplate template that you can copy to build you first jQuery Mobile page. This template contains multiple "page" containers inside, unlike a <a href="page-template.html"> single page template</a> that has just one page within it.</p>
  32. <p>Just view the source and copy the code to get started. All the CSS and JS is linked to the jQuery CDN versions so this is super easy to set up. Remember to include a meta viewport tag in the head to set the zoom level.</p>
  33.  
  34. <p>You link to internal pages by referring to the ID of the page you want to show. For example, to <a href="#two" >link</a> to the page with an ID of "two", my link would have a <code>href="#two"</code> in the code.</p>
  35.  
  36. <h3>Show internal pages:</h3>
  37. <p><a href="#two" data-role="button">Show page "two"</a></p>
  38. <p><a href="#popup"data-role="button" data-rel="dialog" data-transition="pop">Show page "popup" (as a dialog)</a></p>
  39.  
  40.  
  41.  
  42.  
  43. <!-- For example, a link to a page containing multiple internal pages would look like this -->
  44. <p><a href="multipage.html" rel="external">Multi-page link</a></p>
  45.  
  46.  
  47.  
  48.  
  49. </div><!-- /content -->
  50.  
  51.  
  52. <div data-role="footer" data-theme="d">
  53. <h4>Page Footer</h4>
  54. </div><!-- /footer -->
  55. </div><!-- /page one -->
  56.  
  57.  
  58. <!-- Start of second page: #two -->
  59. <div data-role="page" id="two" data-theme="a" data-title="Page two">
  60.  
  61. <div data-role="header">
  62. <h1>Two</h1>
  63.  
  64. </div><!-- /header -->
  65.  
  66. <div data-role="content" data-theme="a">
  67. <h2>Two</h2>
  68. <p>I have an id of "two" on my page container. I'm the second page container in this multi-page template.</p>
  69. <p>Notice that the theme is different for this page because we've added a few <code>data-theme</code> swatch assigments here to show off how flexible it is. You can add any content or widget to these pages, but we're keeping these simple.</p>
  70. <p><a href="#one" data-direction="reverse" data-role="button" data-theme="b">Back to page "one"</a></p>
  71.  
  72. </div><!-- /content -->
  73.  
  74.  
  75. <div data-role="footer">
  76. <h4>Page Footer</h4>
  77. </div><!-- /footer -->
  78. </div><!-- /page two -->
  79.  
  80.  
  81. <!-- Start of third page: #popup -->
  82. <div data-role="page" id="popup">
  83.  
  84. <div data-role="header" data-theme="e">
  85. <h1>Dialog</h1>
  86.  
  87. </div><!-- /header -->
  88.  
  89. <div data-role="content" data-theme="d">
  90. <h2>Popup</h2>
  91. <p>I have an id of "popup" on my page container and only look like a dialog because the link to me had a <code>data-rel="dialog"</code> attribute which gives me this inset look and a <code>data-transition="pop"</code> attribute to change the transition to pop. Without this, I'd be styled as a normal page.</p>
  92. <p><a href="#one" data-rel="back" data-role="button" data-inline="true" data-icon="back">Back to page "one"</a></p>
  93. </div><!-- /content -->
  94.  
  95.  
  96. <div data-role="footer">
  97. <h4>Page Footer</h4>
  98. </div><!-- /footer -->
  99. </div><!-- /page popup -->
  100.  
  101. </body>
  102. </html>
  103. zzzzz

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.