data-attributes.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  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="../../jquery.mobile-1.0.1.min.css" />
  8. <link rel="stylesheet" href="../_assets/css/jqm-docs.css"/>
  9. <script src="../../jquery.js"></script>
  10. <script src="../../experiments/themeswitcher/jquery.mobile.themeswitcher.js"></script>
  11. <script src="../_assets/js/jqm-docs.js"></script>
  12. <script src="../../jquery.mobile-1.0.1.min.js"></script>
  13. </head>
  14. <body>
  15. <div data-role="page" class="type-interior">
  16. <div data-role="header" data-theme="f">
  17. <h1>Data Attributes</h1>
  18. <a href="../../" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
  19. </div><!-- /header -->
  20. <div data-role="content" data-theme="c">
  21. <div class="content-primary">
  22. <h2>Data- attribute reference</h2>
  23. <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>
  24. <style>
  25. table { width:100%; border-bottom:1px solid #ccc; }
  26. th { text-align:left; width: 170px; }
  27. th, td { vertical-align:top; border-top:1px solid #ccc; padding: 6px 10px 4px 0; }
  28. </style>
  29. <h2><a href="../buttons/buttons-types.html">Button</a></h2>
  30. <p>Links with <code>data-role="button"</code>. Input-based buttons and button elements are auto-enhanced, no <code>data-role</code> required</p>
  31. <table>
  32. <tr>
  33. <th>data-corners</th>
  34. <td><strong>true</strong> | false</td>
  35. </tr>
  36. <tr>
  37. <th>data-icon</th>
  38. <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>
  39. </tr>
  40. <tr>
  41. <th>data-iconpos</th>
  42. <td><strong>left</strong> | right | top | bottom | notext</td>
  43. </tr>
  44. <tr>
  45. <th>data-iconshadow</th>
  46. <td><strong>true</strong> | false</td>
  47. </tr>
  48. <tr>
  49. <th>data-inline</th>
  50. <td>true | <strong>false</strong></td>
  51. </tr>
  52. <tr>
  53. <th>data-shadow</th>
  54. <td><strong>true</strong> | false</td>
  55. </tr>
  56. <tr>
  57. <th>data-theme</th>
  58. <td>swatch letter (a-z)</td>
  59. </tr>
  60. </table>
  61. <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>
  62. <h2><a href="../forms/checkboxes/">Checkbox</a></h2>
  63. <p>Pairs of labels and inputs with <code>type="checkbox"</code> are auto-enhanced, no <code>data-role</code> required</p>
  64. <table>
  65. <tr>
  66. <th>data-role</th>
  67. <td>none (prevents auto-enhancement to use native control)</td>
  68. </tr>
  69. <tr>
  70. <th>data-theme</th>
  71. <td>swatch letter (a-z) - Added to the form element</td>
  72. </tr>
  73. </table>
  74. <h2><a href="../content/content-collapsible.html">Collapsible</a></h2>
  75. <p>A heading and content wrapped in a container with the <code>data-role="collapsible"</code></p>
  76. <table>
  77. <tr>
  78. <th>data-collapsed</th>
  79. <td><strong>true</strong> | false</td>
  80. </tr>
  81. <tr>
  82. <th>data-content-theme</th>
  83. <td>swatch letter (a-z)</td>
  84. </tr>
  85. <tr>
  86. <th>data-theme</th>
  87. <td>swatch letter (a-z)</td>
  88. </tr>
  89. </table>
  90. <h2><a href="../content/content-collapsible-set.html">Collapsible set</a></h2>
  91. <p>A number of collapsibles wrapped in a container with the <code>data-role="collapsible-set"</code></p>
  92. <table>
  93. <tr>
  94. <th>data-content-theme</th>
  95. <td>swatch letter (a-z) - Sets all collapsibles in set</td>
  96. </tr>
  97. <tr>
  98. <th>data-theme</th>
  99. <td>swatch letter (a-z) - Sets all collapsibles in set</td>
  100. </tr>
  101. </table>
  102. <h2><a href="../pages/page-dialogs.html">Dialog</a></h2>
  103. <p>Page with <code>data-role="page"</code> linked to with <code>data-rel="dialog"</code> on the anchor.</p>
  104. <table>
  105. <tr>
  106. <th>data-close-btn-text</th>
  107. <td>string (text for the close button, dialog only)</td>
  108. </tr>
  109. <tr>
  110. <th>data-dom-cache</th>
  111. <td>true | <strong>false</strong></td>
  112. </tr>
  113. <tr>
  114. <th>data-fullscreen</th>
  115. <td>true | false (used in conjunction with fixed toolbars)</td>
  116. </tr>
  117. <tr>
  118. <th>data-overlay-theme</th>
  119. <td>swatch letter (a-z) - overlay theme when the page is opened in a dialog</td>
  120. </tr>
  121. <tr>
  122. <th>data-theme</th>
  123. <td>swatch letter (a-z)</td>
  124. </tr>
  125. <tr>
  126. <th>data-title</th>
  127. <td>string (title used when page is shown)</td>
  128. </tr>
  129. </table>
  130. <h2><a href="../pages/page-anatomy.html">Content</a></h2>
  131. <p>Container with <code>data-role="content"</code></p>
  132. <table>
  133. <tr>
  134. <th>data-theme</th>
  135. <td>swatch letter (a-z)</td>
  136. </tr>
  137. </table>
  138. <h2><a href="../forms/docs-forms.html">Field container</a></h2>
  139. <p>Container with <code>data-role="fieldcontain"</code> wrapped around label/form element pair</p>
  140. <h2><a href="../forms/switch/">Flip toggle switch</a></h2>
  141. <p>Select with <code>data-role="slider"</code>, two options only</p>
  142. <table>
  143. <tr>
  144. <th>data-role</th>
  145. <td>none (prevents auto-enhancement to use native control)</td>
  146. </tr>
  147. <tr>
  148. <th>data-theme</th>
  149. <td>swatch letter (a-z) - Added to the form element</td>
  150. </tr>
  151. <tr>
  152. <th>data-track-theme</th>
  153. <td>swatch letter (a-z) - Added to the form element</td>
  154. </tr>
  155. </table>
  156. <h2><a href="../toolbars/docs-footers.html">Footer</a></h2>
  157. <p>Container with <code>data-role="footer"</code></p>
  158. <table>
  159. <tr>
  160. <th>data-id</th>
  161. <td>string (unique id, useful in persistent footers)</td>
  162. </tr>
  163. <tr>
  164. <th>data-position</th>
  165. <td>fixed</td>
  166. </tr>
  167. <tr>
  168. <th>data-theme</th>
  169. <td>swatch letter (a-z)</td>
  170. </tr>
  171. </table>
  172. <h2><a href="../toolbars/docs-headers.html">Header</a></h2>
  173. <p>Container with <code>data-role="header"</code></p>
  174. <table>
  175. <tr>
  176. <th>data-position</th>
  177. <td>fixed</td>
  178. </tr>
  179. <tr>
  180. <th>data-theme</th>
  181. <td>swatch letter (a-z)</td>
  182. </tr>
  183. </table>
  184. <h2><a href="../pages/page-links.html">Link</a></h2>
  185. <p>Links, including those with a <code>data-role="button"</code>, and form submit buttons share these attributes</p>
  186. <table>
  187. <tr>
  188. <th>data-ajax</th>
  189. <td><strong>true</strong> | false</td>
  190. </tr>
  191. <tr>
  192. <th>data-direction</th>
  193. <td>reverse (reverse page transition animation)</td>
  194. </tr>
  195. <tr>
  196. <th>data-dom-cache</th>
  197. <td>true | <strong>false</strong></td>
  198. </tr>
  199. <tr>
  200. <th>data-prefetch</th>
  201. <td>true | <strong>false</strong></td>
  202. </tr>
  203. <tr>
  204. <th>data-rel</th>
  205. <td>back (to move one step back in history)<br />
  206. dialog (to open link styled as dialog, not tracked in history)<br />
  207. external (for linking to another domain)</td>
  208. </tr>
  209. <tr>
  210. <th>data-transition</th>
  211. <td><strong>slide</strong> | slideup | slidedown | pop | fade | flip</td>
  212. </tr>
  213. </table>
  214. <h2><a href="../lists/docs-lists.html">Listview</a></h2>
  215. <p>OL or UL with <code>data-role="listview"</code></p>
  216. <table>
  217. <tr>
  218. <th>data-count-theme</th>
  219. <td>swatch letter (a-z)</td>
  220. </tr>
  221. <tr>
  222. <th>data-dividertheme</th>
  223. <td>swatch letter (a-z)</td>
  224. </tr>
  225. <tr>
  226. <th>data-filter</th>
  227. <td>true | <strong>false</strong></td>
  228. </tr>
  229. <tr>
  230. <th>data-filter-placeholder</th>
  231. <td>string</td>
  232. </tr>
  233. <tr>
  234. <th>data-filter-theme</th>
  235. <td>swatch letter (a-z)</td>
  236. </tr>
  237. <tr>
  238. <th>data-inset</th>
  239. <td>true | <strong>false</strong></td>
  240. </tr>
  241. <tr>
  242. <th>data-split-icon</th>
  243. <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>
  244. </tr>
  245. <tr>
  246. <th>data-split-theme</th>
  247. <td>swatch letter (a-z)<td>
  248. </tr>
  249. <tr>
  250. <th>data-theme</th>
  251. <td>swatch letter (a-z)</td>
  252. </tr>
  253. </table>
  254. <h2><a href="../lists/docs-lists.html">Listview item</a></h2>
  255. <p>LI within a listview</p>
  256. <table>
  257. <tr>
  258. <th>data-filtertext</th>
  259. <td>string (filter by this value instead of inner text)</td>
  260. </tr>
  261. <tr>
  262. <th>data-icon</th>
  263. <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>
  264. </tr>
  265. <tr>
  266. <th>data-role</th>
  267. <td>list-divider</td>
  268. </tr>
  269. <tr>
  270. <th>data-theme</th>
  271. <td>swatch letter (a-z) - can also be set on individual LIs</td>
  272. </tr>
  273. </table>
  274. <h2><a href="../toolbars/docs-navbar.html">Navbar</a></h2>
  275. <p>A number of LIs wrapped in a container with <code>data-role="navbar"</code></p>
  276. <table>
  277. <tr>
  278. <th>data-icon</th>
  279. <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>
  280. </tr>
  281. <tr>
  282. <th>data-iconpos</th>
  283. <td><strong>left</strong> | right | top | bottom | notext</td>
  284. </tr>
  285. <tr>
  286. <th>data-theme</th>
  287. <td>swatch letter (a-z) - can also be set on individual LIs</td>
  288. </tr>
  289. </table>
  290. <h2><a href="../pages/page-anatomy.html">Page</a></h2>
  291. <p>Container with <code>data-role="page"</code></p>
  292. <table>
  293. <tr>
  294. <th>data-add-back-btn</th>
  295. <td>true | <strong>false</strong> (auto add back button, header only)</td>
  296. </tr>
  297. <tr>
  298. <th>data-back-btn-text</th>
  299. <td>string</td>
  300. </tr>
  301. <tr>
  302. <th>data-back-btn-theme</th>
  303. <td>swatch letter (a-z)</td>
  304. </tr>
  305. <tr>
  306. <th>data-close-btn-text</th>
  307. <td>string (text for the close button, dialog only)</td>
  308. </tr>
  309. <tr>
  310. <th>data-dom-cache</th>
  311. <td>true | <strong>false</strong></td>
  312. </tr>
  313. <tr>
  314. <th>data-fullscreen</th>
  315. <td>true | false (used in conjunction with fixed toolbars)</td>
  316. </tr>
  317. <tr>
  318. <th>data-overlay-theme</th>
  319. <td>swatch letter (a-z) - overlay theme when the page is opened in a dialog</td>
  320. </tr>
  321. <tr>
  322. <th>data-theme</th>
  323. <td>swatch letter (a-z)</td>
  324. </tr>
  325. <tr>
  326. <th>data-title</th>
  327. <td>string (title used when page is shown)</td>
  328. </tr>
  329. </table>
  330. <h2><a href="../forms/radiobuttons/">Radio button</a></h2>
  331. <p>Pairs of labels and inputs with <code>type="radio"</code> are auto-enhanced, no <code>data-role</code> required</p>
  332. <table>
  333. <tr>
  334. <th>data-role</th>
  335. <td>none (prevents auto-enhancement to use native control)</td>
  336. </tr>
  337. <tr>
  338. <th>data-theme</th>
  339. <td>swatch letter (a-z) - Added to the form element</td>
  340. </tr>
  341. </table>
  342. <h2><a href="../forms/selects/">Select</a></h2>
  343. <p>All <code>select</code> form elements are auto-enhanced, no <code>data-role</code> required</p>
  344. <table>
  345. <tr>
  346. <th>data-icon</th>
  347. <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>
  348. </tr>
  349. <tr>
  350. <th>data-iconpos</th>
  351. <td><strong>left</strong> | right | top | bottom | notext</td>
  352. </tr>
  353. <tr>
  354. <th>data-inline</th>
  355. <td>true | <strong>false</strong></td>
  356. </tr>
  357. <tr>
  358. <th>data-native-menu</th>
  359. <td><strong>true</strong> | false</td>
  360. </tr>
  361. <tr>
  362. <th>data-overlay-theme</th>
  363. <td>swatch letter (a-z) - overlay theme for non-native selects</td>
  364. </tr>
  365. <tr>
  366. <th>data-placeholder</th>
  367. <td>true | false - Add to the Option</td>
  368. </tr>
  369. <tr>
  370. <th>data-role</th>
  371. <td>none (prevents auto-enhancement to use native control)</td>
  372. </tr>
  373. <tr>
  374. <th>data-theme</th>
  375. <td>swatch letter (a-z) - Added to the form element</td>
  376. </tr>
  377. </table>
  378. <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>
  379. <h2><a href="../forms/slider/">Slider</a></h2>
  380. <p>Inputs with <code>type="range"</code> are auto-enhanced, no <code>data-role</code> required</p>
  381. <table>
  382. <tr>
  383. <th>data-role</th>
  384. <td>none (prevents auto-enhancement to use native control)</td>
  385. </tr>
  386. <tr>
  387. <th>data-theme</th>
  388. <td>swatch letter (a-z) - Added to the form element</td>
  389. </tr>
  390. <tr>
  391. <th>data-track-theme</th>
  392. <td>swatch letter (a-z) - Added to the form element</td>
  393. </tr>
  394. </table>
  395. <h2><a href="../forms/textinputs/">Text input &amp; Textarea</a></h2>
  396. <p>Input <code>type="text|number|search|etc."</code> or <code>textarea</code> elements are auto-enhanced, no <code>data-role</code> required</p>
  397. <table>
  398. <tr>
  399. <th>data-role</th>
  400. <td>none (prevents auto-enhancement to use native control)</td>
  401. </tr>
  402. <tr>
  403. <th>data-theme</th>
  404. <td>swatch letter (a-z) - Added to the form element</td>
  405. </tr>
  406. </table>
  407. </div><!--/content -->
  408. <div class="content-secondary">
  409. <div data-role="collapsible" data-collapsed="true" data-theme="b" data-content-theme="d">
  410. <h3>More in this section</h3>
  411. <ul data-role="listview" data-theme="c" data-dividertheme="d">
  412. <li data-role="list-divider">API</li>
  413. <li><a href="../../docs/api/globalconfig.html">Configuring defaults</a></li>
  414. <li><a href="../../docs/api/events.html">Events</a></li>
  415. <li><a href="../../docs/api/methods.html">Methods &amp; Utilities</a></li>
  416. <li data-theme="a"><a href="../../docs/api/data-attributes.html">Data attribute reference</a></li>
  417. <li><a href="../../docs/api/themes.html">Theme framework</a></li>
  418. </ul>
  419. </div>
  420. </div>
  421. </div><!-- /content -->
  422. <div data-role="footer" class="footer-docs" data-theme="c">
  423. <p>&copy; 2011-2012 The jQuery Project</p>
  424. </div>
  425. </div><!-- /page -->
  426. </body>
  427. </html>