Skip to content

Commit fb1c8be

Browse files
committed
Added a non-adax form submit example. Improved the styling of the forms and confirmation pages.
1 parent d0fe757 commit fb1c8be

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

docs/forms/forms-sample-response.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@
2727

2828
<h2>You Chose:</h2>
2929

30-
30+
<div class="ui-body ui-body-d ui-corner-all">
3131

3232
<?php
3333
echo "<p> " . $_REQUEST['shipping'] . "</p>";
3434
?>
35-
35+
36+
</div>
37+
38+
<a href="forms-sample.html" data-role="button" data-theme="b" data-icon="arrow-l">Change shipping method</a>
3639

3740
</form>
3841

docs/forms/forms-sample.html

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,42 @@ <h2>Ajax form submission</h2>
2727

2828
<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>
2929
<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>
30-
31-
<h2>Non-Ajax handling</h2>
32-
33-
<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 of Ajax form handling completely via the <code>ajaxEnabled</code> <a href="../api/globalconfig.html">global config option</a>.</p>
30+
3431

35-
<h2>Simple Ajax form example</h2>
36-
<p>This page demonstrates automated ajax handling of form submissions. The form below is configured to send regular 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>
37-
<form action="forms-sample-response.php" method="get">
32+
<h2>Default Ajax form example</h2>
33+
<p>This demonstrates automated ajax handling of form submissions. The form below is configured to send regular 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>
34+
<form action="forms-sample-response.php" method="get" class="ui-body ui-body-a ui-corner-all">
35+
<fieldset>
36+
<div data-role="fieldcontain">
37+
<label for="shipping" class="select">Shipping method:</label>
38+
<select name="shipping" id="shipping">
39+
<option value="Standard shipping">Standard: 7 day</option>
40+
<option value="Rush shipping">Rush: 3 days</option>
41+
<option value="Express shipping">Express: next day</option>
42+
<option value="Overnight shipping">Overnight</option>
43+
</select>
44+
</div>
45+
<button type="submit" data-theme="b" name="submit" value="submit-value">Submit</button>
46+
</fieldset>
47+
</form>
48+
49+
<h2>Non-Ajax form example</h2>
50+
51+
<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 of Ajax form handling completely via the <code>ajaxEnabled</code> <a href="../api/globalconfig.html">global config option</a>.</p>
52+
53+
<p>The form below is identical to the one above except for the addition of the <code>data-ajax="false"</code> attribute attribute. When the submit button is pressed, it will result in a full page refresh.</p>
54+
<form action="forms-sample-response.php" method="get" data-ajax="false" class="ui-body ui-body-a ui-corner-all">
3855
<fieldset>
3956
<div data-role="fieldcontain">
40-
<label for="shipping" class="select">Choose shipping method:</label>
57+
<label for="shipping" class="select">Shipping method:</label>
4158
<select name="shipping" id="shipping">
4259
<option value="Standard shipping">Standard: 7 day</option>
4360
<option value="Rush shipping">Rush: 3 days</option>
4461
<option value="Express shipping">Express: next day</option>
4562
<option value="Overnight shipping">Overnight</option>
4663
</select>
4764
</div>
48-
<button type="submit" data-theme="a" name="submit" value="submit-value">Submit</button>
65+
<button type="submit" data-theme="b" name="submit" value="submit-value">Submit</button>
4966
</fieldset>
5067
</form>
5168

0 commit comments

Comments
 (0)