Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge remote branch 'origin/master'

  • Loading branch information...
commit db3dbc04d23a23bb6e7a7e0ca94b244de1c15c8f 2 parents 7be8311 + 557da74
scottjehl authored
View
2  docs/api/globalconfig.html
@@ -92,7 +92,7 @@
<dd>The class assigned to page currently in view, and during transitions</dd>
- <dt><code>activeBtnClass</code> <em>string</em>, default: "ui-page-active"</dt>
+ <dt><code>activeBtnClass</code> <em>string</em>, default: "ui-btn-active"</dt>
<dd>The class used for "active" button state, from CSS framework.</dd>
<dt><code>ajaxEnabled</code> <em>boolean</em>, default: true</dt>
View
7 docs/forms/forms-sample-response.php
@@ -27,12 +27,15 @@
<h2>You Chose:</h2>
-
+ <div class="ui-body ui-body-d ui-corner-all">
<?php
echo "<p> " . $_REQUEST['shipping'] . "</p>";
?>
-
+
+ </div>
+
+ <a href="forms-sample.html" data-role="button" data-theme="b" data-icon="arrow-l">Change shipping method</a>
</form>
View
35 docs/forms/forms-sample.html
@@ -27,17 +27,34 @@
<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>
<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>
-
- <h2>Non-Ajax handling</h2>
-
- <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>
+
- <h2>Simple Ajax form example</h2>
- <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>
- <form action="forms-sample-response.php" method="get">
+ <h2>Default Ajax form example</h2>
+ <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>
+ <form action="forms-sample-response.php" method="get" class="ui-body ui-body-a ui-corner-all">
+ <fieldset>
+ <div data-role="fieldcontain">
+ <label for="shipping" class="select">Shipping method:</label>
+ <select name="shipping" id="shipping">
+ <option value="Standard shipping">Standard: 7 day</option>
+ <option value="Rush shipping">Rush: 3 days</option>
+ <option value="Express shipping">Express: next day</option>
+ <option value="Overnight shipping">Overnight</option>
+ </select>
+ </div>
+ <button type="submit" data-theme="b" name="submit" value="submit-value">Submit</button>
+ </fieldset>
+ </form>
+
+ <h2>Non-Ajax form example</h2>
+
+ <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>
+
+ <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>
+ <form action="forms-sample-response.php" method="get" data-ajax="false" class="ui-body ui-body-a ui-corner-all">
<fieldset>
<div data-role="fieldcontain">
- <label for="shipping" class="select">Choose shipping method:</label>
+ <label for="shipping" class="select">Shipping method:</label>
<select name="shipping" id="shipping">
<option value="Standard shipping">Standard: 7 day</option>
<option value="Rush shipping">Rush: 3 days</option>
@@ -45,7 +62,7 @@
<option value="Overnight shipping">Overnight</option>
</select>
</div>
- <button type="submit" data-theme="a" name="submit" value="submit-value">Submit</button>
+ <button type="submit" data-theme="b" name="submit" value="submit-value">Submit</button>
</fieldset>
</form>
View
54 js/jquery.mobile.navigation.js 100644 → 100755
@@ -832,17 +832,39 @@
return;
}
+ var settings = $.extend( {}, $.mobile.changePage.defaults, options );
+
+ // Make sure we have a pageContainer to work with.
+ settings.pageContainer = settings.pageContainer || $.mobile.pageContainer;
+
+ // Make sure we have a fromPage.
+ settings.fromPage = settings.fromPage || $.mobile.activePage;
+
+ var mpc = settings.pageContainer,
+ pbcEvent = new $.Event( "pagebeforechange" ),
+ triggerData = { toPage: toPage, options: settings };
+
+ // Let listeners know we're about to change the current page.
+ mpc.trigger( pbcEvent, triggerData );
+
+ mpc.trigger( "beforechangepage", triggerData ); // XXX: DEPRECATED for 1.0
+
+ // If the default behavior is prevented, stop here!
+ if( pbcEvent.isDefaultPrevented() ){
+ return;
+ }
+
+ // We allow "pagebeforechange" observers to modify the toPage in the trigger
+ // data to allow for redirects. Make sure our toPage is updated.
+
+ toPage = triggerData.toPage;
+
// Set the isPageTransitioning flag to prevent any requests from
// entering this method while we are in the midst of loading a page
// or transitioning.
isPageTransitioning = true;
- var settings = $.extend( {}, $.mobile.changePage.defaults, options );
-
- // Make sure we have a pageContainer to work with.
- settings.pageContainer = settings.pageContainer || $.mobile.pageContainer;
-
// If the caller passed us a url, call loadPage()
// to make sure it is loaded into the DOM. We'll listen
// to the promise object it returns so we know when
@@ -863,16 +885,16 @@
//release transition lock so navigation is free again
releasePageTransitionLock();
- settings.pageContainer.trigger("changepagefailed");
+ settings.pageContainer.trigger( "pagechangefailed", triggerData );
+ settings.pageContainer.trigger( "changepagefailed", triggerData ); // XXX: DEPRECATED for 1.0
});
return;
}
// The caller passed us a real page DOM element. Update our
// internal state and then trigger a transition to the page.
- var mpc = settings.pageContainer,
- fromPage = $.mobile.activePage,
- url = toPage.jqmData( "url" ),
+ var fromPage = settings.fromPage,
+ url = ( settings.dataUrl && path.convertUrlToDataUrl( settings.dataUrl ) ) || toPage.jqmData( "url" ),
// The pageUrl var is usually the same as url, except when url is obscured as a dialog url. pageUrl always contains the file path
pageUrl = url,
fileUrl = path.getFilePath( url ),
@@ -882,9 +904,6 @@
pageTitle = document.title,
isDialog = settings.role === "dialog" || toPage.jqmData( "role" ) === "dialog";
- // Let listeners know we're about to change the current page.
- mpc.trigger( "beforechangepage" );
-
// If we are trying to transition to the same page that we are currently on ignore the request.
// an illegal same page request is defined by the current page being the same as the url, as long as there's history
// and toPage is not an array or object (those are allowed to be "same")
@@ -893,7 +912,8 @@
// to the same page.
if( fromPage && fromPage[0] === toPage[0] ) {
isPageTransitioning = false;
- mpc.trigger( "changepage" );
+ mpc.trigger( "pagechange", triggerData );
+ mpc.trigger( "changepage", triggerData ); // XXX: DEPRECATED for 1.0
return;
}
@@ -980,7 +1000,9 @@
releasePageTransitionLock();
// Let listeners know we're all done changing the current page.
- mpc.trigger( "changepage" );
+ mpc.trigger( "pagechange", triggerData );
+
+ mpc.trigger( "changepage", triggerData ); // XXX: DEPRECATED for 1.0
});
};
@@ -992,7 +1014,9 @@
role: undefined, // By default we rely on the role defined by the @data-role attribute.
duplicateCachedPage: undefined,
pageContainer: undefined,
- showLoadMsg: true //loading message shows by default when pages are being fetched during changePage
+ showLoadMsg: true, //loading message shows by default when pages are being fetched during changePage
+ dataUrl: undefined,
+ fromPage: undefined
};
/* Event Bindings - hashchange, submit, and click */
Please sign in to comment.
Something went wrong with that request. Please try again.