index.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 - Search input</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>Search input</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">
  21. <div class="content-primary">
  22. <form action="#" method="get">
  23. <h2>Search input</h2>
  24. <ul data-role="controlgroup" data-type="horizontal" class="localnav">
  25. <li><a href="index.html" data-role="button" data-transition="fade" class="ui-btn-active">Basics</a></li>
  26. <li><a href="options.html" data-role="button" data-transition="fade">Options</a></li>
  27. <li><a href="methods.html" data-role="button" data-transition="fade">Methods</a></li>
  28. <li><a href="events.html" data-role="button" data-transition="fade">Events</a></li>
  29. </ul>
  30. <p>Search inputs are a new HTML type that is styled with pill-shaped corners and adds a "x" icon to clear the field once you start typing. Start with an <code>input</code> with a <code>type="search"</code> attribute in your markup. View the <a href="../../api/data-attributes.html">data- attribute reference</a> to see all the possible attributes you can add to search inputs.</p>
  31. <p>Set the <code>for</code> attribute of the <code>label</code> to match the ID of the <code>input</code> so they are semantically associated. It's possible to <a href="../docs-forms.html">accessibly hide the label</a> if it's not desired in the page layout, but we require that it is present in the markup for semantic and accessibility reasons.</p>
  32. <pre><code>
  33. &lt;label for=&quot;search-basic&quot;&gt;Search Input:&lt;/label&gt;
  34. &lt;input type=&quot;search&quot; name=&quot;search&quot; id=&quot;searc-basic&quot; value=&quot;&quot; /&gt;
  35. </code></pre>
  36. <p>This will produce a basic search input. The default styles set the width of the input to 100% of the parent container and stacks the label on a separate line.</p>
  37. <label for="search-basic">Search Input:</label>
  38. <input type="search" name="search" id="search-basic" value="" />
  39. <p>Optionally wrap the search input in a container with the <code>data-role="fieldcontain"</code> attribute to help visually group it in a longer form.</p>
  40. <pre><code>
  41. <strong>&lt;div data-role=&quot;fieldcontain&quot;&gt;
  42. </strong> &lt;label for=&quot;search&quot;&gt;Search Input:&lt;/label&gt;
  43. &lt;input type=&quot;search&quot; name=&quot;password&quot; id=&quot;search&quot; value=&quot;&quot; /&gt;
  44. <strong>&lt;/div&gt;
  45. </strong></code></pre>
  46. <p>The search input is now displayed like this:</p>
  47. <div data-role="fieldcontain">
  48. <label for="search">Search Input:</label>
  49. <input type="search" name="search2" id="search" value="" />
  50. </div>
  51. <p>Themed variation:</p>
  52. <div data-role="fieldcontain">
  53. <label for="searchA">Search Input:</label>
  54. <input type="search" name="search3" id="searchA" value="" data-theme="a" />
  55. </div>
  56. <h2>Calling the textinput plugin</h2>
  57. <p>This plugin will auto initialize on any page that contains a text input with the <code>type="search"</code> attribute, no need for a <code>data-role</code> attribute in the markup. However, if needed you can directly call the <code>textinput</code> plugin on a selector, just like any jQuery plugin:</p>
  58. <pre><code>
  59. $('.mySearchInput').textinput();
  60. </code></pre>
  61. </form>
  62. </div><!--/content-primary -->
  63. <div class="content-secondary">
  64. <div data-role="collapsible" data-collapsed="true" data-theme="b" data-content-theme="d">
  65. <h3>More in this section</h3>
  66. <ul data-role="listview" data-theme="c" data-dividertheme="d">
  67. <li data-role="list-divider">Form elements</li>
  68. <li><a href="../docs-forms.html">Form basics</a></li>
  69. <li><a href="../forms-all.html">Form element gallery</a></li>
  70. <li><a href="../textinputs/index.html">Text inputs</a></li>
  71. <li data-theme="a"><a href="index.html">Search input</a></li>
  72. <li><a href="../slider/">Slider</a></li>
  73. <li><a href="../switch/">Flip toggle switch</a></li>
  74. <li><a href="../radiobuttons/">Radio buttons</a></li>
  75. <li><a href="../checkboxes/">Checkboxes</a></li>
  76. <li><a href="../selects/">Select menus</a></li>
  77. <li><a href="../forms-themes.html">Theming forms</a></li>
  78. <li><a href="../forms-all-native.html">Native form elements</a></li>
  79. <li><a href="../forms-sample.html">Submitting forms</a></li>
  80. </ul>
  81. </div>
  82. </div>
  83. </div><!-- /content -->
  84. <div data-role="footer" class="footer-docs" data-theme="c">
  85. <p>&copy; 2011-2012 The jQuery Project</p>
  86. </div>
  87. </div><!-- /page -->
  88. </body>
  89. </html>