Revert "Export"
[framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.1.0 / docs / forms / forms-sample.html
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 - Sample Form Submit</title>
7         <link rel="stylesheet"  href="../../css/themes/default/jquery.mobile.css" />
8         <link rel="stylesheet" href="../_assets/css/jqm-docs.css"/>
9
10         <script src="../../js/jquery.js"></script>
11         <script src="../../docs/_assets/js/jqm-docs.js"></script>
12         <script src="../../js/"></script>
13
14 </head>
15 <body>
16
17         <div data-role="page" class="type-interior">
18
19                 <div data-role="header" data-theme="f">
20                 <h1>Forms</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 -->
24
25         <div data-role="content">
26                         <div class="content-primary">
27
28                         <h2>Ajax form submission</h2>
29
30                         <p>In jQuery Mobile, form submissions are automatically handled using Ajax whenever possible, creating a smooth transition between the form and the result page. To ensure your form submits as intended, be sure to specify <code>action</code> and <code>method</code> properties on your form element. When unspecified, the method will default to <code>get</code>, and the <code>action</code> will default to the current page's relative path (found via <code>$.mobile.path.get()</code>)</p>
31                         <p>Forms also accept attributes for transitions just like anchors, such as <code>data-transition="pop"</code> and <code>data-direction="reverse"</code>. To submit a form without Ajax, you can either disable Ajax form handling globally, or per form via the <code>data-ajax="false"</code> attribute. The <code>target</code> attribute (as in <code>target="_blank"</code>) is respected on forms as well, and will default to the browser's handling of that target when the form submits. Note that unlike anchors, the <code>rel</code> attribute is not allowed on forms.</p>
32
33
34             <h2>Default Ajax form example</h2>
35             <p>This demonstrates automated ajax handling of form submissions. The form below is configured to send a <code>GET</code> request to <code>forms-sample-response.php</code>. On submit, jQuery Mobile will make sure that the Url specified is able to be retrieved via Ajax, and handle it appropriately. Keep in mind that just like ordinary HTTP form submissions, jQuery Mobile allows <code>GET</code> result pages to be bookmarked by updating the URL hash when the response returns successfully. Also like ordinary form submissions, <code>POST</code> requests do not contain query parameters in the hash, so they are not bookmarkable.</p>
36                         <form action="forms-sample-response.php" method="get" class="ui-body ui-body-a ui-corner-all">
37                                 <fieldset>
38                                         <div data-role="fieldcontain">
39                                                 <label for="shipping" class="select">Shipping method:</label>
40                                                 <select name="shipping" id="shipping">
41                                                         <option value="Standard shipping">Standard: 7 day</option>
42                                                         <option value="Rush shipping">Rush: 3 days</option>
43                                                         <option value="Express shipping">Express: next day</option>
44                                                         <option value="Overnight shipping">Overnight</option>
45                                                 </select>
46                                         </div>
47                                         <button type="submit" data-theme="b" name="submit" value="submit-value">Submit</button>
48                                 </fieldset>
49                         </form>
50
51                         <h2>Non-Ajax form example</h2>
52
53                          <p>To prevent form submissions from being automatically handled with Ajax, add the <code>data-ajax="false"</code> attribute to the form element. You can also turn off Ajax form handling completely via the <code>ajaxEnabled</code> <a href="../api/globalconfig.html">global config option</a>.</p>
54
55             <p>The form below is identical to the one above except for the addition of the <code>data-ajax="false"</code> attribute. When the submit button is pressed, it will result in a full page refresh.</p>
56                         <form action="forms-sample-response.php" method="get" data-ajax="false" class="ui-body ui-body-a ui-corner-all">
57                                 <fieldset>
58                                         <div data-role="fieldcontain">
59                                                 <label for="shipping" class="select">Shipping method:</label>
60                                                 <select name="shipping" id="shipping">
61                                                         <option value="Standard shipping">Standard: 7 day</option>
62                                                         <option value="Rush shipping">Rush: 3 days</option>
63                                                         <option value="Express shipping">Express: next day</option>
64                                                         <option value="Overnight shipping">Overnight</option>
65                                                 </select>
66                                         </div>
67                                         <button type="submit" data-theme="b" name="submit" value="submit-value">Submit</button>
68                                 </fieldset>
69                         </form>
70
71                         <h2>Self-submitting Forms</h2>
72                         <p>You can submit forms to the same URL you're currently viewing by setting the form's <code>action</code> attribute to that URL. <A href="forms-sample-selfsubmit.php">This page demonstrates.</a></p>
73                         <p>When a <code>POST</code> request is submitted to a page that's already in the DOM (which would commonly happen when submitting a form to the same URL currently in view), the response URL will be identical to that existing page, as <code>POST</code> requests do not append query string parameters to the URL. In this situation, jQuery Mobile will replace the page that submitted the form with the page returned in the response body.</p>
74
75                         </div><!--/content-primary -->
76
77                         <div class="content-secondary">
78
79                                 <div data-role="collapsible" data-collapsed="true" data-theme="b" data-content-theme="d">
80
81                                                 <h3>More in this section</h3>
82
83                                                 <ul data-role="listview" data-theme="c" data-dividertheme="d">
84
85                                                         <li data-role="list-divider">Form elements</li>
86                                                         <li><a href="docs-forms.html">Form basics</a></li>
87                                                         <li><a href="forms-all.html">Form element gallery</a></li>
88                                                         <li><a href="forms-all-mini.html">Mini form element gallery</a></li>
89               <li><a href="textinputs/">Text inputs</a></li>
90                                                         <li><a href="search/">Search inputs</a></li>
91                                                         <li><a href="slider/">Slider</a></li>
92                                                         <li><a href="switch/">Flip toggle switch</a></li>
93                                                         <li><a href="radiobuttons/">Radio buttons</a></li>
94                                                         <li><a href="checkboxes/">Checkboxes</a></li>
95                                                         <li><a href="selects/">Select menus</a></li>
96                                                         <li><a href="forms-themes.html">Theming forms</a></li>
97                                                         <li><a href="forms-all-native.html">Native form elements</a></li>
98                                                         <li data-theme="a"><a href="forms-sample.html">Submitting forms</a></li>
99
100
101                                                 </ul>
102                                 </div>
103                         </div>
104
105                 </div><!-- /content -->
106
107                 <div data-role="footer" class="footer-docs" data-theme="c">
108                                 <p>&copy; 2011-12 The jQuery Foundation</p>
109                 </div>
110
111                 </div><!-- /page -->
112
113                 </body>
114                 </html>