Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 7ad1e84

Browse files
added more information about active state for navbar items
1 parent 02cd324 commit 7ad1e84

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

docs/toolbars/docs-navbar.html

+15-2
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,25 @@ <h1>Navbar</h1>
2727
<h2>Simple navbar</h2>
2828

2929
<p>jQuery Mobile has a very basic navbar widget that is useful for providing up to 5 buttons with optional icons in a bar, typically within a header or footer. There is also a <a href="footer-persist-a.html">persistent navbar</a> variation that works more like a tab bar that stays fixed as you navigate across pages.</p>
30-
<p>A navbar is coded as an unordered list of links wrapped in a container element that has the <code> data-role="navbar"</code> attribute. To set one of the links to the active (selected) state, add <code>class="ui-btn-active"</code> to the anchor. In this example, we have a two-button navbar with the "One" item set to active:</p>
30+
<p>A navbar is coded as an unordered list of links wrapped in a container element that has the <code> data-role="navbar"</code> attribute. This is an example of a two-button navbar:</p>
3131

3232
<pre><code>
3333
<strong>&lt;div data-role=&quot;navbar&quot;&gt;</strong>
3434
&lt;ul&gt;
35-
&lt;li&gt;&lt;a href=&quot;a.html&quot; class=&quot;ui-btn-active&quot;&gt;One&lt;/a&gt;&lt;/li&gt;
35+
&lt;li&gt;&lt;a href=&quot;a.html&quot;&gt;One&lt;/a&gt;&lt;/li&gt;
36+
&lt;li&gt;&lt;a href=&quot;b.html&quot;&gt;Two&lt;/a&gt;&lt;/li&gt;
37+
&lt;/ul&gt;
38+
<strong>&lt;/div&gt;&lt;!-- /navbar --&gt;</strong>
39+
</code></pre>
40+
41+
<p>When a link in the navbar is clicked it gets the active (selected) state. The <code>ui-btn-active</code> class is first removed from all anchors in the navbar before it is added to the activated link. If this is a link to another page, the class will be removed again after the transition has completed.</p>
42+
43+
<p>To set an item to the active state upon initialization of the navbar, add <code>class="ui-btn-active"</code> to the corresponding anchor in your markup. Additionaly add a class of <code>ui-state-persist</code> to make the framework restore the active state each time the page is shown while it exists in the DOM. The example below shows a navbar with item "One" set to active:</p>
44+
45+
<pre><code>
46+
<strong>&lt;div data-role=&quot;navbar&quot;&gt;</strong>
47+
&lt;ul&gt;
48+
&lt;li&gt;&lt;a href=&quot;a.html&quot; class=&quot;ui-btn-active ui-state-persist&quot;&gt;One&lt;/a&gt;&lt;/li&gt;
3649
&lt;li&gt;&lt;a href=&quot;b.html&quot;&gt;Two&lt;/a&gt;&lt;/li&gt;
3750
&lt;/ul&gt;
3851
<strong>&lt;/div&gt;&lt;!-- /navbar --&gt;</strong>

docs/toolbars/footer-persist-a.html

+6-6
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@ <h2>About persistent toolbars</h2>
3333
&lt;div data-role=&quot;footer&quot;<strong> data-id=&quot;foo1&quot; data-position=&quot;fixed&quot;</strong>&gt;
3434
&lt;div data-role=&quot;navbar&quot;&gt;
3535
&lt;ul&gt;
36-
&lt;li&gt;&lt;a href=&quot;d.html&quot;&gt;Info&lt;/a&gt;&lt;/li&gt;
37-
&lt;li&gt;&lt;a href=&quot;a.html&quot;&gt;Friends&lt;/a&gt;&lt;/li&gt;
38-
&lt;li&gt;&lt;a href=&quot;b.html&quot;&gt;Albums&lt;/a&gt;&lt;/li&gt;
39-
&lt;li&gt;&lt;a href=&quot;c.html&quot;&gt;Emails&lt;/a&gt;&lt;/li&gt;
36+
&lt;li&gt;&lt;a href=&quot;a.html&quot;&gt;Info&lt;/a&gt;&lt;/li&gt;
37+
&lt;li&gt;&lt;a href=&quot;b.html&quot;&gt;Friends&lt;/a&gt;&lt;/li&gt;
38+
&lt;li&gt;&lt;a href=&quot;c.html&quot;&gt;Albums&lt;/a&gt;&lt;/li&gt;
39+
&lt;li&gt;&lt;a href=&quot;d.html&quot;&gt;Emails&lt;/a&gt;&lt;/li&gt;
4040
&lt;/ul&gt;
4141
&lt;/div&gt;&lt;!-- /navbar --&gt;
4242
&lt;/div&gt;&lt;!-- /footer --&gt;
4343
</code></pre>
44-
<p>To set the active state of an item in a persistent toolbar, add a class of <code>ui-state-persist</code> in addition to <code>ui-btn-active</code> to the corresponding anchor.</p>
44+
<p>To set the active state of an item in a persistent toolbar, add <code>class="ui-btn-active ui-state-persist"</code> to the corresponding anchor.</p>
4545

4646
<pre><code>
47-
&lt;li&gt;&lt;a href=&quot;d.html&quot; <strong>class=&quot;ui-btn-active ui-state-persist&quot;</strong>&gt;Info&lt;/a&gt;&lt;/li&gt;
47+
&lt;li&gt;&lt;a href=&quot;a.html&quot; <strong>class=&quot;ui-btn-active ui-state-persist&quot;</strong>&gt;Info&lt;/a&gt;&lt;/li&gt;
4848
</code></pre>
4949

5050
<h3>A note about transitions</h3>

0 commit comments

Comments
 (0)