5 <meta name="viewport" content="width=device-width, initial-scale=1">
6 <title>jQuery Mobile Docs - Data Attribute Reference</title>
7 <link rel="stylesheet" href="../../css/themes/default/jquery.mobile.css" />
8 <link rel="stylesheet" href="../_assets/css/jqm-docs.css"/>
10 <script src="../../js/jquery.js"></script>
11 <script src="../../docs/_assets/js/jqm-docs.js"></script>
12 <script src="../../js/"></script>
17 <div data-role="page" class="type-interior">
19 <div data-role="header" data-theme="f">
20 <h1>Data Attributes</h1>
21 <a href="../../" data-icon="home" data-iconpos="notext" data-direction="reverse">Home</a>
22 <a href="../nav.html" data-icon="search" data-iconpos="notext" data-rel="dialog" data-transition="fade">Search</a>
23 </div><!-- /header -->
25 <div data-role="content" data-theme="c">
27 <div class="content-primary">
28 <h2>Data- attribute reference</h2>
29 <p>The jQuery Mobile framework uses HTML5 <code>data-</code> attributes to allow for markup-based initialization and configuration of widgets. These attributes are completely optional; calling plugins manually and passing options directly is also supported. To avoid naming conflicts with other plugins or frameworks that also use <code>data-</code> attributes, set a custom namespace by modifying the <a href="globalconfig.html"><code>ns</code> global option</a>.<p>
32 table { width:100%; border-bottom:1px solid #ccc; }
33 th { text-align:left; width: 170px; }
34 th, td { vertical-align:top; border-top:1px solid #ccc; padding: 6px 10px 4px 0; }
37 <h2><a href="../buttons/buttons-types.html">Button</a></h2>
38 <p>Links with <code>data-role="button"</code>. Input-based buttons and button elements are auto-enhanced, no <code>data-role</code> required</p>
42 <td><strong>true</strong> | false</td>
46 <td>home | delete | plus | arrow-u | arrow-d | check | gear | grid | star | custom | arrow-r | arrow-l | minus | refresh | forward | back | alert | info | search</td>
50 <td><strong>left</strong> | right | top | bottom | notext</td>
53 <th>data-iconshadow</th>
54 <td><strong>true</strong> | false</td>
58 <td>true | <strong>false</strong></td>
62 <td>true | <strong>false</strong> - Compact sized version</td>
66 <td><strong>true</strong> | false</td>
70 <td>swatch letter (a-z)</td>
73 <p>Multiple buttons can be wrapped in a container with a <code>data-role="controlgroup"</code> attribute for a vertically grouped set. Add the <code>data-type="horizontal"</code> attribute for the buttons to sit side-by-side.</p>
76 <h2><a href="../forms/checkboxes/">Checkbox</a></h2>
77 <p>Pairs of labels and inputs with <code>type="checkbox"</code> are auto-enhanced, no <code>data-role</code> required</p>
81 <td>true | <strong>false</strong> - Compact sized version</td>
85 <td>none (prevents auto-enhancement to use native control)</td>
89 <td>swatch letter (a-z) - Added to the form element</td>
93 <h2><a href="../content/content-collapsible.html">Collapsible</a></h2>
94 <p>A heading and content wrapped in a container with the <code>data-role="collapsible"</code></p>
97 <th>data-collapsed</th>
98 <td><strong>true</strong> | false</td>
101 <th>data-content-theme</th>
102 <td>swatch letter (a-z)</td>
105 <th>data-iconpos</th>
106 <td><strong>left</strong> | right | top | bottom | notext</td>
110 <td>true | <strong>false</strong> - Compact sized version</td>
114 <td>swatch letter (a-z)</td>
118 <h2><a href="../content/content-collapsible-set.html">Collapsible set</a></h2>
119 <p>A number of collapsibles wrapped in a container with the <code>data-role="collapsible-set"</code></p>
122 <th>data-content-theme</th>
123 <td>swatch letter (a-z) - Sets all collapsibles in set</td>
126 <th>data-iconpos</th>
127 <td><strong>left</strong> | right | top | bottom | notext</td>
131 <td>true | <strong>false</strong> - Compact sized version</td>
135 <td>swatch letter (a-z) - Sets all collapsibles in set</td>
139 <h2><a href="../pages/page-anatomy.html">Content</a></h2>
140 <p>Container with <code>data-role="content"</code></p>
144 <td>swatch letter (a-z)</td>
148 <h2><a href="../pages/page-dialogs.html">Dialog</a></h2>
149 <p>Page with <code>data-role="page"</code> linked to with <code>data-rel="dialog"</code> on the anchor.</p>
152 <th>data-close-btn-text</th>
153 <td>string (text for the close button, dialog only)</td>
156 <th>data-dom-cache</th>
157 <td>true | <strong>false</strong></td>
160 <th>data-overlay-theme</th>
161 <td>swatch letter (a-z) - overlay theme when the page is opened in a dialog</td>
165 <td>swatch letter (a-z)</td>
169 <td>string (title used when page is shown)</td>
173 <h2><a href="globalconfig.html">Enhancement</a></h2>
174 <p>Container with <code>data-enhance="false"</code> or <code>data-ajax="false"</code></p>
177 <th>data-enhance</th>
178 <td><strong>true</strong> | false</td>
182 <td><strong>true</strong> | false</td>
185 <p>Any DOM elements inside a <code>data-enhance="false"</code> container, save for <code>data-role="page|dialog"</code> elements, will be ignored during initial enhancement and subsequent <code>create</code> events provided that the <code>$.mobile.ignoreContentEnabled</code> flag is set prior to the enhancement (eg in a <code>mobileinit</code> binding).</p>
187 <p>Any link or form elements inside <code>data-enhance="false"</code> containers will be ignored by the framework's navigation functionality when <code>$.mobile.ignoreContentEnabled</code> is set to true.</p>
189 <h2><a href="../forms/docs-forms.html">Field container</a></h2>
190 <p>Container with <code>data-role="fieldcontain"</code> wrapped around label/form element pair</p>
192 <h2><a href="../forms/switch/">Flip toggle switch</a></h2>
193 <p>Select with <code>data-role="slider"</code>, two options only</p>
197 <td>true | <strong>false</strong> - Compact sized version</td>
201 <td>none (prevents auto-enhancement to use native control)</td>
205 <td>swatch letter (a-z) - Added to the form element</td>
208 <th>data-track-theme</th>
209 <td>swatch letter (a-z) - Added to the form element</td>
213 <h2><a href="../toolbars/docs-footers.html">Footer</a></h2>
214 <p>Container with <code>data-role="footer"</code></p>
218 <td>string (unique id, useful in persistent footers)</td>
221 <th>data-position</th>
225 <th>data-fullscreen</th>
226 <td>true (used in conjunction with fixed toolbars)</td>
230 <td>swatch letter (a-z)</td>
234 <h2><a href="../toolbars/docs-headers.html">Header</a></h2>
235 <p>Container with <code>data-role="header"</code></p>
238 <th>data-position</th>
242 <th>data-fullscreen</th>
243 <td>true (used in conjunction with fixed toolbars)</td>
247 <td>swatch letter (a-z)</td>
251 <h2><a href="../pages/page-links.html">Link</a></h2>
252 <p>Links, including those with a <code>data-role="button"</code>, and form submit buttons share these attributes</p>
256 <td><strong>true</strong> | false</td>
259 <th>data-direction</th>
260 <td>reverse (reverse page transition animation)</td>
263 <th>data-dom-cache</th>
264 <td>true | <strong>false</strong></td>
267 <th>data-prefetch</th>
268 <td>true | <strong>false</strong></td>
272 <td>back (to move one step back in history)<br />
273 dialog (to open link styled as dialog, not tracked in history)<br />
274 external (for linking to another domain)</td>
277 <th>data-transition</th>
278 <td><strong>slide</strong> | slideup | slidedown | pop | fade | flip</td>
282 <h2><a href="../lists/docs-lists.html">Listview</a></h2>
283 <p>OL or UL with <code>data-role="listview"</code></p>
286 <th>data-count-theme</th>
287 <td>swatch letter (a-z)</td>
290 <th>data-divider-theme</th>
291 <td>swatch letter (a-z)</td>
295 <td>true | <strong>false</strong></td>
298 <th>data-filter-placeholder</th>
302 <th>data-filter-theme</th>
303 <td>swatch letter (a-z)</td>
307 <td>true | <strong>false</strong></td>
310 <th>data-split-icon</th>
311 <td>home | delete | plus | arrow-u | arrow-d | check | gear | grid | star | custom | arrow-r | arrow-l | minus | refresh | forward | back | alert | info | search</td>
314 <th>data-split-theme</th>
315 <td>swatch letter (a-z)<td>
319 <td>swatch letter (a-z)</td>
323 <h2><a href="../lists/docs-lists.html">Listview item</a></h2>
324 <p>LI within a listview</p>
327 <th>data-filtertext</th>
328 <td>string (filter by this value instead of inner text)</td>
332 <td>home | delete | plus | arrow-u | arrow-d | check | gear | grid | star | custom | arrow-r | arrow-l | minus | refresh | forward | back | alert | info | search</td>
336 <td>list-divider</td>
340 <td>swatch letter (a-z) - can also be set on individual LIs</td>
343 <h2><a href="../toolbars/docs-navbar.html">Navbar</a></h2>
344 <p>A number of LIs wrapped in a container with <code>data-role="navbar"</code></p>
348 <td>home | delete | plus | arrow-u | arrow-d | check | gear | grid | star | custom | arrow-r | arrow-l | minus | refresh | forward | back | alert | info | search</td>
351 <th>data-iconpos</th>
352 <td><strong>left</strong> | right | top | bottom | notext</td>
356 <td>swatch letter (a-z) - can also be set on individual LIs</td>
359 <h2><a href="../pages/page-anatomy.html">Page</a></h2>
360 <p>Container with <code>data-role="page"</code></p>
363 <th>data-add-back-btn</th>
364 <td>true | <strong>false</strong> (auto add back button, header only)</td>
367 <th>data-back-btn-text</th>
371 <th>data-back-btn-theme</th>
372 <td>swatch letter (a-z)</td>
375 <th>data-close-btn-text</th>
376 <td>string (text for the close button, dialog only)</td>
379 <th>data-dom-cache</th>
380 <td>true | <strong>false</strong></td>
383 <th>data-fullscreen</th>
384 <td>true (used in conjunction with fixed toolbars) <p class="ui-bar-e">Deprecated in 1.1 - use on header and footer instead.</p></td>
387 <th>data-overlay-theme</th>
388 <td>swatch letter (a-z) - overlay theme when the page is opened in a dialog</td>
392 <td>swatch letter (a-z)</td>
396 <td>string (title used when page is shown)</td>
400 <h2><a href="../forms/radiobuttons/">Radio button</a></h2>
401 <p>Pairs of labels and inputs with <code>type="radio"</code> are auto-enhanced, no <code>data-role</code> required</p>
405 <td>true | <strong>false</strong> - Compact sized version</td>
409 <td>none (prevents auto-enhancement to use native control)</td>
413 <td>swatch letter (a-z) - Added to the form element</td>
417 <h2><a href="../forms/selects/">Select</a></h2>
418 <p>All <code>select</code> form elements are auto-enhanced, no <code>data-role</code> required</p>
422 <td>home | delete | plus | arrow-u | arrow-d | check | gear | grid | star | custom | arrow-r | arrow-l | minus | refresh | forward | back | alert | info | search</td>
425 <th>data-iconpos</th>
426 <td><strong>left</strong> | right | top | bottom | notext</td>
430 <td>true | <strong>false</strong></td>
434 <td>true | <strong>false</strong> - Compact sized version</td>
437 <th>data-native-menu</th>
438 <td><strong>true</strong> | false</td>
441 <th>data-overlay-theme</th>
442 <td>swatch letter (a-z) - overlay theme for non-native selects</td>
445 <th>data-placeholder</th>
446 <td>true | false - Add to the Option</td>
450 <td>none (prevents auto-enhancement to use native control)</td>
454 <td>swatch letter (a-z) - Added to the form element</td>
457 <p>Multiple selects can be wrapped in a fieldset with a <code>data-role="controlgroup"</code> attribute for a vertically grouped set. Add the <code>data-type="horizontal"</code> attribute for the selects to sit side-by-side.</p>
459 <h2><a href="../forms/slider/">Slider</a></h2>
460 <p>Inputs with <code>type="range"</code> are auto-enhanced, no <code>data-role</code> required</p>
463 <th>data-highlight</th>
464 <td>true | <strong>false</strong> - Adds an active state fill on track to handle</td>
468 <td>true | <strong>false</strong> - Compact sized version</td>
472 <td>none (prevents auto-enhancement to use native control)</td>
476 <td>swatch letter (a-z) - Added to the form element</td>
479 <th>data-track-theme</th>
480 <td>swatch letter (a-z) - Added to the form element</td>
484 <h2><a href="../forms/textinputs/">Text input & Textarea</a></h2>
485 <p>Input <code>type="text|number|search|etc."</code> or <code>textarea</code> elements are auto-enhanced, no <code>data-role</code> required</p>
489 <td>true | <strong>false</strong> - Compact sized version</td>
493 <td>none (prevents auto-enhancement to use native control)</td>
497 <td>swatch letter (a-z) - Added to the form element</td>
501 </div><!--/content -->
503 <div class="content-secondary">
505 <div data-role="collapsible" data-collapsed="true" data-theme="b" data-content-theme="d">
507 <h3>More in this section</h3>
509 <ul data-role="listview" data-theme="c" data-dividertheme="d">
511 <li data-role="list-divider">API</li>
512 <li><a href="../../docs/api/globalconfig.html">Configuring defaults</a></li>
513 <li><a href="../../docs/api/events.html">Events</a></li>
514 <li><a href="../../docs/api/methods.html">Methods & Utilities</a></li>
515 <li data-theme="a"><a href="../../docs/api/data-attributes.html">Data attribute reference</a></li>
516 <li><a href="../../docs/api/themes.html">Theme framework</a></li>
521 </div><!-- /content -->
523 <div data-role="footer" class="footer-docs" data-theme="c">
524 <p>© 2011-12 The jQuery Foundation</p>