diff --git a/docs/forms/docs-forms.html b/docs/forms/docs-forms.html index df42b651..11b429f8 100755 --- a/docs/forms/docs-forms.html +++ b/docs/forms/docs-forms.html @@ -1,15 +1,15 @@ - - + +
- -jQuery Mobile provides a complete set of finger-friendly form elements that are based on native HTML form elements.
- +All forms should be wrapped in a form tag that has an action and method that will handle the form data processing on the server.
<form action="form.php" method="post">
...
@@ -37,10 +37,10 @@
Auto-initialization of form elements
By default, jQuery Mobile will automatically enhance certain native form controls into rich touch-friendly components. This is handled internally by finding form elements by tag name and running a plugin method on them, so for instance, a select element will be found and initialized with the "selectmenu" plugin, while an input element with a type="checkbox" will be enhanced with the "checkboxradio" plugin. Once initialized, you can address these enhanced components programmatically through their jQuery UI widget API methods (see documentation on available methods here: Form Plugin Methods).
-
+
Preventing auto-initialization of form elements
If you'd prefer that a particular form control be left untouched by jQuery Mobile, simply give that element the attribute data-role="none". For example:
-
+
<label for="foo">
<select name="foo" id="foo" data-role="none">
<option value="a" >A</option>
@@ -48,34 +48,36 @@
<option value="c" >C</option>
</select>
-
-
+
+
Or, if you'd like to prevent auto-initialization without adding attributes to your markup, you can customize the selector that is used for preventing auto-initialization by setting the page plugin's keepNative option (which defaults to "[data-role="none"]. Be sure to configure this option inside an event handler bound to the mobileinit event, so that it applies to the first page as well as subsequent pages that are loaded.
$(document).bind('mobileinit',function(){
$.mobile.page.prototype.options.keepNative = "select, input.foo, textarea.bar";
-});
+});
-
+
+One special case is that of selects. The above sample will prevent any and all augmentation from taking place on select elements in the page if select is included. If you wish to retain the native performance, look/feel of the menu itself and benefit from the visual augmentation of the select button by jQuery Mobile you can set $.mobile.nativeSelectMenu to true in a mobileinit callback as a global setting or use data-native="true" on a case by case basis.
+
Dynamic form layout
In jQuery Mobile, all form elements are designed to be a flexible width so they will comfortably fit the width of any mobile device. One optimization built into the framework is that we present labels and form elements differently based on screen width.
- If a page is fairly narrow (~480px), the labels are styled as block-level elements so they will stack on top of the form element to save horizontal space.
+ If a page is fairly narrow (~480px), the labels are styled as block-level elements so they will stack on top of the form element to save horizontal space.
On wider screens, the labels and form elements are styled to be on the same line in a 2-column layout to take advantage of the screen real estate.
Field containers
-
+
To improve the styling to labels and form elements on wider screens, we recommend wrapping a div or fieldset with the data-role="fieldcontain" attribute around each label/form element. The framework will add a thin vertical bottom border on this container to act as a field separator and visually align the label and form elements for quick scanning.
-
+
<div data-role="fieldcontain">
...label/input code goes here...
</div>
-
-
+
+
If a select menu contains optgroup elements, jQuery Mobile will create a divider & group items based on the label attribute's text:
If the multiple attribute is present in your markup, jQuery Mobile will enhance the element with a few extra considerations:
When a select is large enough to where the menu will open in a new page, the placeholder text is displayed in the button when no items are selected, and the label text is displayed in the menu's header. This differs from smaller overlay menus where the placeholder text is displayed in both the button and the header, and from full-page single selects where the placeholder text is not used at all.
You can specify any jQuery Mobile button data- attribute on a select element too. In this example, we're setting the theme, icon and inline properties though data- attributes.
- +You can specify any jQuery Mobile button data- attribute on a select element too. In this example, we're setting the theme, icon and inline properties though data- attributes.
+