mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-04-29 10:24:45 +00:00
added boilerplate pages
This commit is contained in:
parent
fcb3fea35d
commit
30f11b9f60
3 changed files with 170 additions and 59 deletions
|
|
@ -23,22 +23,22 @@
|
|||
|
||||
<p>A jQuery Mobile site must start with an HTML5 'doctype' to take full advantage of all of the framework's features. (Older devices with browsers that don't understand HTML5 will safely ignore the 'doctype' and various custom attributes.) In the 'head', references to jQuery, jQuery Mobile and the mobile theme CSS are all required to start things off:</p>
|
||||
|
||||
<div class="highlight">
|
||||
<pre><span class="cp"><!DOCTYPE html></span>
|
||||
<span class="nt"><html></span>
|
||||
<span class="nt"><head></span>
|
||||
<span class="nt"><meta</span> <span class="na">charset=</span><span class="s">"UTF-8"</span> <span class="nt">/></span>
|
||||
<span class="nt"><title></span>Page Title<span class="nt"></title></span>
|
||||
<span class="nt"><link</span> <span class="na">rel=</span><span class="s">"stylesheet"</span> <span class="na">type=</span><span class="s">"text/css"</span> <span class="na">href=</span><span class="s">"ui-theme.css"</span> <span class="nt">/></span>
|
||||
<span class="nt"><script </span><span class="na">type=</span><span class="s">"text/javascript"</span> <span class="na">src=</span><span class="s">"jquery-min.js"</span><span class="nt">></script></span>
|
||||
<span class="nt"><script </span><span class="na">type=</span><span class="s">"text/javascript"</span> <span class="na">src=</span><span class="s">"jquery-mobile-min.js"</span><span class="nt">></script></span>
|
||||
<span class="nt"></head></span>
|
||||
<span class="nt"><body></span>
|
||||
...
|
||||
<span class="nt"></body></span>
|
||||
<span class="nt"></html></span>
|
||||
</pre>
|
||||
</div>
|
||||
<pre></code>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Page Title</title>
|
||||
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.css" />
|
||||
<script src="http://code.jquery.com/jquery-1.4.3.min.js"></script>
|
||||
<script src="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
...
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</code></pre>
|
||||
|
||||
<p>Inside the <code><body></code> tag, each view or "page" on the mobile device is identified with an element (usually a <code>div</code>) with the <code>data-role="page"</code> attribute:</p>
|
||||
|
||||
|
|
@ -65,26 +65,37 @@
|
|||
|
||||
<p>Putting it all together, this is the standard boilerplate page template you should start with:</p>
|
||||
|
||||
<div class="highlight">
|
||||
<pre><span class="cp"><!DOCTYPE html></span>
|
||||
<span class="nt"><html></span>
|
||||
<span class="nt"><head></span>
|
||||
<span class="nt"><meta</span> <span class="na">charset=</span><span class="s">"UTF-8"</span> <span class="nt">/></span>
|
||||
<span class="nt"><title></span>Page Title<span class="nt"></title></span>
|
||||
<span class="nt"><link</span> <span class="na">rel=</span><span class="s">"stylesheet"</span> <span class="na">type=</span><span class="s">"text/css"</span> <span class="na">href=</span><span class="s">"ui-theme.css"</span> <span class="nt">/></span>
|
||||
<span class="nt"><script </span><span class="na">type=</span><span class="s">"text/javascript"</span> <span class="na">src=</span><span class="s">"jquery-min.js"</span><span class="nt">></script></span>
|
||||
<span class="nt"><script </span><span class="na">type=</span><span class="s">"text/javascript"</span> <span class="na">src=</span><span class="s">"jquery-mobile-min.js"</span><span class="nt">></script></span>
|
||||
<span class="nt"></head></span>
|
||||
<span class="nt"><body></span>
|
||||
<span class="nt"><div</span> <span class="na">data-role=</span><span class="s">"page"</span><span class="nt">></span>
|
||||
<span class="nt"><div</span> <span class="na">data-role=</span><span class="s">"header"</span><span class="nt">></span>...<span class="nt"></div></span>
|
||||
<span class="nt"><div</span> <span class="na">data-role=</span><span class="s">"content"</span><span class="nt">></span>...<span class="nt"></div></span>
|
||||
<span class="nt"><div</span> <span class="na">data-role=</span><span class="s">"footer"</span><span class="nt">></span>...<span class="nt"></div></span>
|
||||
<span class="nt"></div></span>
|
||||
<span class="nt"></body></span>
|
||||
<span class="nt"></html></span>
|
||||
</pre>
|
||||
</div>
|
||||
<pre></code>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Page Title</title>
|
||||
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.css" />
|
||||
<script src="http://code.jquery.com/jquery-1.4.3.min.js"></script>
|
||||
<script src="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div data-role="page">
|
||||
|
||||
<div data-role="header">
|
||||
<h1>Page Title</h1>
|
||||
</div><!-- /header -->
|
||||
|
||||
<div data-role="content">
|
||||
<p>Page content goes here.</p>
|
||||
</div><!-- /content -->
|
||||
|
||||
<div data-role="footer">
|
||||
<h4>Page Footer</h4>
|
||||
</div><!-- /header -->
|
||||
</div><!-- /page -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</code></pre>
|
||||
|
||||
<a href="page-template.html" data-inline="true" data-theme="b" data-role="button">View boilerplate template</a>
|
||||
|
||||
<h2>External page linking</h2>
|
||||
|
||||
|
|
@ -98,34 +109,58 @@
|
|||
|
||||
<h2>Local, internal linked "pages"</h2>
|
||||
|
||||
<p>A single HTML document can contain either a single 'page' or multiple 'pages' can be assembled and loaded together by stacking multiple divs with a <code>data-role</code> of <code>"page"</code>. This allows you to build a small site or application within a single HTML document; jQuery Mobile will simply display the first 'page' it finds in the source order when the page loads.</p>
|
||||
<p>A single HTML document can contain multiple 'pages' that are loaded together by stacking multiple divs with a <code>data-role</code> of <code>"page"</code>. Each 'page' block needs a unique ID (<code>id="foo"</code>) that will be used to link internally btweent 'pages' (<code>href="#foo"</code>). When a link is clicked, the framework will look for an internal 'page' with the ID and transition it into view.</p>
|
||||
|
||||
<p>If a link points to an anchor (<code>#foo</code>), the framework will looks for a page with that ID. If it finds a page in the HTML document, it will transition the new page into view.</p>
|
||||
<p>It's important to note if your are linking from a mobile page that was loaded via Ajax to a page with multiple internal pages, you need to add a <code>rel="external"</code> to the link. This tells the framework to do a full page reload to clear out the Ajax hash in the URL. This is critical because Ajax pages use the hash (#) to track the Ajax history, while multiple internal pages use the hash to indicate internal pages so there will be a conflicts.</p>
|
||||
<p>For example, a link to a page containing multiple internal pages would look like this:</p>
|
||||
|
||||
<p>Here is an example of a 2 "page" site built with two jQuery Mobile divs navigated by linking to an ID placed on each page wrapper. Note that the IDs on the page wrappers are only needed to support the internal page linking, and are optional if each page is a separate HTML document.</p>
|
||||
<code><a href="multipage.html" rel="external">Multi-page link</a></code>
|
||||
|
||||
<p>Here is an example of a 2 "page" site built with two jQuery Mobile divs navigated by linking to an ID placed on each page wrapper. Note that the IDs on the page wrappers are only needed to support the internal page linking, and are optional if each page is a separate HTML document. Here is what two pages look inside the <code>body</code> element.</p>
|
||||
|
||||
<pre>
|
||||
<div class="highlight">
|
||||
<code><span class="nt"><div</span> <span class="na">data-role=</span><span class="s">"page"</span> <span class="na">id=</span><span class="s">"foo"</span><span class="nt">></span>
|
||||
<span class="nt"><div</span> <span class="na">data-role=</span><span class="s">"content"</span><span class="nt">></span>
|
||||
I'm the "foo" page. Since I'm the first page
|
||||
in the source order, I will be displayed onLoad.
|
||||
<span class="nt"><a</span> <span class="na">href=</span><span class="s">"#bar"</span><span class="nt">></span>Visit the bar "page"<span class="nt"></a></span>
|
||||
<span class="nt"></div><!-- /content --></span>
|
||||
<span class="nt"></div><!-- /foo page --></span>
|
||||
<pre></code>
|
||||
<body>
|
||||
|
||||
<span class="nt"><div</span> <span class="na">data-role=</span><span class="s">"page"</span> <span class="na">id=</span><span class="s">"bar"</span><span class="nt">></span>
|
||||
<span class="nt"><div</span> <span class="na">data-role=</span><span class="s">"content"</span><span class="nt">></span>
|
||||
I'm the "bar" page. I will be shown only if the
|
||||
anchor link on the <span class="nt"><a</span> <span class="na">href=</span><span class="s">"#foo"</span><span class="nt">></span>foo<span class="nt"></a></span>
|
||||
page is clicked.
|
||||
<span class="nt"></div></span><span class="nt"><!-- /content --></span>
|
||||
<span class="nt"></div><!-- /bar page --></span>
|
||||
</code>
|
||||
</div>
|
||||
</pre>
|
||||
<!-- Start of first page -->
|
||||
<div data-role="page" id="foo">
|
||||
|
||||
<p>You can seamlessly navigate between local, internal "pages" and external pages in jQuery Mobile. Both will look the same to the end user except that external pages will display the Ajax spinner while loading. In either situation, jQuery Mobile updates the page's URL hash to enable Back button support, deep-linking and bookmarking. </p>
|
||||
<div data-role="header">
|
||||
<h1>Foo</h1>
|
||||
</div><!-- /header -->
|
||||
|
||||
<div data-role="content">
|
||||
<p>I'm first in the source order so I'm shown as the page.</p>
|
||||
<p>View internal page called <a href="#bar">bar</a></p>
|
||||
</div><!-- /content -->
|
||||
|
||||
<div data-role="footer">
|
||||
<h4>Page Footer</h4>
|
||||
</div><!-- /header -->
|
||||
</div><!-- /page -->
|
||||
|
||||
|
||||
<!-- Start of second page -->
|
||||
<div data-role="page" id="bar">
|
||||
|
||||
<div data-role="header">
|
||||
<h1>Bar</h1>
|
||||
</div><!-- /header -->
|
||||
|
||||
<div data-role="content">
|
||||
<p>I'm first in the source order so I'm shown as the page.</p>
|
||||
<p><a href="#foo">Back to foo</a></p>
|
||||
</div><!-- /content -->
|
||||
|
||||
<div data-role="footer">
|
||||
<h4>Page Footer</h4>
|
||||
</div><!-- /header -->
|
||||
</div><!-- /page -->
|
||||
</body>
|
||||
</code></pre>
|
||||
|
||||
<a href="multipage-template.html" data-inline="true" data-theme="b" data-role="button" rel="external">View multi-page template</a>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p>PLEASE NOTE: Since we are using the hash to track navigation history for all the Ajax 'pages', it's not currently possible to deep link to an anchor (<code>index.html#foo</code>) on a page in jQuery Mobile, because the framework will look for a 'page' with and <code>ID</code> of <code>#foo</code> instead of the native behavior of scrolling to the content with that <code>ID</code>.</p>
|
||||
|
||||
|
|
|
|||
49
docs/pages/multipage-template.html
Executable file
49
docs/pages/multipage-template.html
Executable file
|
|
@ -0,0 +1,49 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Page Title</title>
|
||||
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.css" />
|
||||
<script src="http://code.jquery.com/jquery-1.4.3.min.js"></script>
|
||||
<script src="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- Start of first page -->
|
||||
<div data-role="page" id="foo">
|
||||
|
||||
<div data-role="header">
|
||||
<h1>Foo</h1>
|
||||
</div><!-- /header -->
|
||||
|
||||
<div data-role="content">
|
||||
<h2>Foo</h2>
|
||||
<p>I'm first in the source order so I'm shown as the page.</p>
|
||||
<p>View internal page called <a href="#bar">bar</a></p>
|
||||
</div><!-- /content -->
|
||||
|
||||
<div data-role="footer">
|
||||
<h4>Page Footer</h4>
|
||||
</div><!-- /header -->
|
||||
</div><!-- /page -->
|
||||
|
||||
|
||||
<!-- Start of second page -->
|
||||
<div data-role="page" id="bar">
|
||||
|
||||
<div data-role="header">
|
||||
<h1>Bar</h1>
|
||||
</div><!-- /header -->
|
||||
|
||||
<div data-role="content">
|
||||
<h2>Bar</h2>
|
||||
<p>I'm first in the source order so I'm shown as the page.</p>
|
||||
<p><a href="#foo">Back to foo</a></p>
|
||||
</div><!-- /content -->
|
||||
|
||||
<div data-role="footer">
|
||||
<h4>Page Footer</h4>
|
||||
</div><!-- /header -->
|
||||
</div><!-- /page -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
27
docs/pages/page-template.html
Executable file
27
docs/pages/page-template.html
Executable file
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Page Title</title>
|
||||
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.css" />
|
||||
<script src="http://code.jquery.com/jquery-1.4.3.min.js"></script>
|
||||
<script src="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div data-role="page">
|
||||
|
||||
<div data-role="header">
|
||||
<h1>Page Title</h1>
|
||||
</div><!-- /header -->
|
||||
|
||||
<div data-role="content">
|
||||
<p>Page content goes here.</p>
|
||||
</div><!-- /content -->
|
||||
|
||||
<div data-role="footer">
|
||||
<h4>Page Footer</h4>
|
||||
</div><!-- /header -->
|
||||
</div><!-- /page -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in a new issue