diff --git a/docs/_assets/css/jqm-docs.css b/docs/_assets/css/jqm-docs.css index b361a150..f467d646 100644 --- a/docs/_assets/css/jqm-docs.css +++ b/docs/_assets/css/jqm-docs.css @@ -13,7 +13,7 @@ body { background: #dddddd; } .ui-mobile #jqm-version { text-indent: -99999px; background: url(../images/version.png) top right no-repeat; width: 119px; height: 122px; overflow: hidden; position: absolute; z-index: 50; top: 0; right: 0; } .ui-mobile .jqm-themeswitcher { margin: 10px 25px 10px 10px; } -h2 { margin-top:1.5em; } +h2 { margin:1.2em 0 .4em 0; } p code { font-size:1.2em; font-weight:bold; } dt { font-weight: bold; margin: 2em 0 .5em; } @@ -74,6 +74,49 @@ p.intro strong { margin: 0; } +/* new API additions */ + +dt { + margin: 35px 0 15px 0; + background-color:#ddd; + font-weight:normal; +} +dt code { + display:inline-block; + font-weight:bold; + color:#56A00E; + padding:3px 7px; + margin-right:10px; + background-color:#fff; +} +dd { + margin-bottom:10px; +} +dd .default { font-weight:bold; } +dd pre { + margin:0 0 0 0; +} +dd code { font-weight: normal; } +dd pre code { + margin:0; + border:none; + font-weight:normal; + font-size:100%; + background-color:transparent; +} +dd h4 { margin:15px 0 0 0; } + +.localnav { + margin:0 0 20px 0; + overflow:hidden; +} +.localnav li { + float:left; +} +.localnav .ui-btn-inner { + padding: .6em 10px; + font-size:80%; +} /* F bar theme - just for the docs overview headers */ diff --git a/docs/forms/docs-forms.html b/docs/forms/docs-forms.html index e1965ee3..a2f6a9d5 100755 --- a/docs/forms/docs-forms.html +++ b/docs/forms/docs-forms.html @@ -134,7 +134,7 @@ myswitch .slider("refresh");
  • Flip toggle switch
  • Radio buttons
  • Checkboxes
  • -
  • Select menus
  • +
  • Select menus
  • Theming forms
  • Native form elements
  • Submitting forms
  • diff --git a/docs/forms/forms-all-native.html b/docs/forms/forms-all-native.html index 83c83f10..c8814941 100755 --- a/docs/forms/forms-all-native.html +++ b/docs/forms/forms-all-native.html @@ -224,7 +224,7 @@
  • Flip toggle switch
  • Radio buttons
  • Checkboxes
  • -
  • Select menus
  • +
  • Select menus
  • Theming forms
  • Native form elements
  • Submitting forms
  • diff --git a/docs/forms/forms-all.html b/docs/forms/forms-all.html index 1fc2714e..53b1b90f 100755 --- a/docs/forms/forms-all.html +++ b/docs/forms/forms-all.html @@ -222,7 +222,7 @@
  • Flip toggle switch
  • Radio buttons
  • Checkboxes
  • -
  • Select menus
  • +
  • Select menus
  • Theming forms
  • Native form elements
  • Submitting forms
  • diff --git a/docs/forms/forms-checkboxes.html b/docs/forms/forms-checkboxes.html index e5a09807..9b7835dc 100755 --- a/docs/forms/forms-checkboxes.html +++ b/docs/forms/forms-checkboxes.html @@ -130,7 +130,7 @@ $("input[type='checkbox']").attr("checked",true).checkboxradio("refresh");
  • Flip toggle switch
  • Radio buttons
  • Checkboxes
  • -
  • Select menus
  • +
  • Select menus
  • Theming forms
  • Native form elements
  • Submitting forms
  • diff --git a/docs/forms/forms-radiobuttons.html b/docs/forms/forms-radiobuttons.html index 95b13f63..d650818e 100755 --- a/docs/forms/forms-radiobuttons.html +++ b/docs/forms/forms-radiobuttons.html @@ -134,7 +134,7 @@ $("input[type='radio']").attr("checked",true).checkboxradio("refresh");
  • Flip toggle switch
  • Radio buttons
  • Checkboxes
  • -
  • Select menus
  • +
  • Select menus
  • Theming forms
  • Native form elements
  • Submitting forms
  • diff --git a/docs/forms/forms-sample.html b/docs/forms/forms-sample.html index 832078c0..203b23e3 100755 --- a/docs/forms/forms-sample.html +++ b/docs/forms/forms-sample.html @@ -68,7 +68,7 @@
  • Flip toggle switch
  • Radio buttons
  • Checkboxes
  • -
  • Select menus
  • +
  • Select menus
  • Theming forms
  • Native form elements
  • Submitting forms
  • diff --git a/docs/forms/forms-search.html b/docs/forms/forms-search.html index b4a7ce97..3462a31f 100755 --- a/docs/forms/forms-search.html +++ b/docs/forms/forms-search.html @@ -72,7 +72,7 @@
  • Flip toggle switch
  • Radio buttons
  • Checkboxes
  • -
  • Select menus
  • +
  • Select menus
  • Theming forms
  • Native form elements
  • Submitting forms
  • diff --git a/docs/forms/forms-slider.html b/docs/forms/forms-slider.html index 1f07af54..511b8033 100755 --- a/docs/forms/forms-slider.html +++ b/docs/forms/forms-slider.html @@ -82,7 +82,7 @@ $("input[type=range]").val(60).slider("refresh");
  • Flip toggle switch
  • Radio buttons
  • Checkboxes
  • -
  • Select menus
  • +
  • Select menus
  • Theming forms
  • Native form elements
  • Submitting forms
  • diff --git a/docs/forms/forms-switch.html b/docs/forms/forms-switch.html index 7c368b70..9308d065 100755 --- a/docs/forms/forms-switch.html +++ b/docs/forms/forms-switch.html @@ -79,7 +79,7 @@ myswitch .slider("refresh");
  • Flip toggle switch
  • Radio buttons
  • Checkboxes
  • -
  • Select menus
  • +
  • Select menus
  • Theming forms
  • Native form elements
  • Submitting forms
  • diff --git a/docs/forms/forms-text.html b/docs/forms/forms-text.html index 916e3392..2b846f03 100755 --- a/docs/forms/forms-text.html +++ b/docs/forms/forms-text.html @@ -127,7 +127,7 @@
  • Flip toggle switch
  • Radio buttons
  • Checkboxes
  • -
  • Select menus
  • +
  • Select menus
  • Theming forms
  • Native form elements
  • Submitting forms
  • diff --git a/docs/forms/forms-themes.html b/docs/forms/forms-themes.html index 951360fc..8139b806 100755 --- a/docs/forms/forms-themes.html +++ b/docs/forms/forms-themes.html @@ -383,7 +383,7 @@
  • Flip toggle switch
  • Radio buttons
  • Checkboxes
  • -
  • Select menus
  • +
  • Select menus
  • Theming forms
  • Native form elements
  • Submitting forms
  • diff --git a/docs/forms/index.html b/docs/forms/index.html index 20b8b05a..9b0571ba 100755 --- a/docs/forms/index.html +++ b/docs/forms/index.html @@ -33,7 +33,7 @@
  • Flip toggle switch
  • Radio buttons
  • Checkboxes
  • -
  • Select menus
  • +
  • Select menus
  • Theming forms
  • Native form elements
  • Submitting forms
  • diff --git a/docs/forms/plugin-eventsmethods.html b/docs/forms/plugin-eventsmethods.html index 9fc9c8c9..f5e597c0 100755 --- a/docs/forms/plugin-eventsmethods.html +++ b/docs/forms/plugin-eventsmethods.html @@ -196,7 +196,7 @@ $('input').button('disable');
  • Flip toggle switch
  • Radio buttons
  • Checkboxes
  • -
  • Select menus
  • +
  • Select menus
  • Theming forms
  • Native form elements
  • Submitting forms
  • diff --git a/docs/forms/selects/events.html b/docs/forms/selects/events.html new file mode 100644 index 00000000..4fe48f8c --- /dev/null +++ b/docs/forms/selects/events.html @@ -0,0 +1,101 @@ + + + + + + jQuery Mobile Docs - Select events + + + + + + + + + +
    + +
    +

    Select Menus

    + Home +
    + +
    +
    + +
    + +

    Select menus

    + + + +

    Since the native select menu is used as a proxy for the custom select, you can watch for events on the original, native select instead of needing to go through the select menu plugin. Bind to the change event by type: change, blur, focus, keypress, click, etc.

    +
     
    +$( ".selector" ).bind( "change", function(event, ui) {
    +  ...
    +});
    +
    + +

    The select menu plugin has the following custom events:

    + +
    + +
    create triggered when a select menu is created
    +
    +

    This event is used to find out when a custom select was created. It is not used to create a custom select. The select create event can be used like this:

    + +
    
    +$( ".selector" ).selectmenu({
    +   create: function(event, ui) { ... }
    +});		
    +			
    +
    + +
    + +
    +
    + + + +
    + + + +
    + + + + diff --git a/docs/forms/forms-selects.html b/docs/forms/selects/forms-selects.html similarity index 98% rename from docs/forms/forms-selects.html rename to docs/forms/selects/forms-selects.html index 77fba79d..0b0cbc56 100644 --- a/docs/forms/forms-selects.html +++ b/docs/forms/selects/forms-selects.html @@ -10,6 +10,10 @@ + @@ -26,6 +30,13 @@

    Select menus

    + +
    + Basics + Options + Methods + Events +

    The select menus are driven off native select elements, but the native selects are hidden from view and replaced with a custom-styled select button that matches the look and feel of the jQuery Mobile framework. The replacement selects are ARIA-enabled and are keyboard accessible on the desktop as well.

    diff --git a/docs/forms/selects/index.html b/docs/forms/selects/index.html new file mode 100644 index 00000000..6a42aaa2 --- /dev/null +++ b/docs/forms/selects/index.html @@ -0,0 +1,487 @@ + + + + + + jQuery Mobile Docs - Select + + + + + + + + + +
    + +
    +

    Select Menus

    + Home +
    + +
    +
    + + + +

    Select menus

    + + + +

    The select menus are driven off native select elements, but the native selects are hidden from view and replaced with a custom-styled select button that matches the look and feel of the jQuery Mobile framework. The replacement selects are ARIA-enabled and are keyboard accessible on the desktop as well.

    + +

    When the select button is clicked, the native select menu picker for the OS will open. When a value is selected in the menu, the custom select button is updated to match the new selection.

    + +

    To add a select widget to your page, start with a standard select element populated with a set of option elements. Set the for attribute of the label to match the ID of the select so they are semantically associated. Wrap them in a div with the data-role="fieldcontain" attribute to help visually group it in a longer form.

    + +

    The framework will find all select elements and automatically enhance them into the custom select menus. Here is a typical select menu grouped in a fieldc container to style the label and select together:

    + +
    
    +<div data-role="fieldcontain">
    +	<label for="select-choice-1" class="select">Choose shipping method:</label>
    +	<select name="select-choice-1" id="select-choice-1">
    +		<option value="standard">Standard: 7 day</option>
    +		<option value="rush">Rush: 3 days</option>
    +		<option value="express">Express: next day</option>
    +		<option value="overnight">Overnight</option>
    +	</select>
    +</div>
    +
    + +

    This produces this select:

    + + +
    + + +
    + +

    Here is an example of a select with a long list of options:

    + +
    + + +
    + +

    This example organizes the options with optgroup elements and has a disabled option.

    + +
    + + +
    + +

    Note that on some mobile platforms, the native select menus don't support multiple selection via the multiple="multiple" attribute. If this feature is required, we recommend using custom menus. + +

    Programmatically calling the select menu plugin

    + +

    The select menu plugin will auto initialize on any page that contains a select menu, no need for a data-role attribute in the markup. However, you can directly call the select menu plugin on any selector, just like any normal jQuery plugin:

    +
    
    +$('select').selectmenu();			
    +
    + +

    Option to use custom menus

    +

    You can optionally use custom-styled select menus instead of the native versions. This adds the ability to theme the menu to better match the look and feel of your site and provides visual consistency across platforms. In addition, it supports multiple selection, restores missing functionality on certain platforms such as optgroup support on Android, and adds an elegant way to handle placeholder values (explained below). Lastly, the custom menus will look better on desktop browsers because native menus on the desktop tend to be fairly small compared their mobile counterparts and this can look a bit odd if desktop is a priority for your project.

    + +

    Keep in mind that there is overhead involved in parsing the native select to build a custom menu. If there are a lot of selects on a page, or a select has a long list of options, this can impact the performance of the page so we recommend using custom menus sparingly.

    + +

    To use custom menus on a specific select, just add the data-native-menu="false" attribute. Alternately, this can also programmatically set the select menu's nativeMenu configuration option to false in a callback bound to the mobileinit event to achieve the same effect. This will globally make all selects use the custom menu by default. The following must be included in the page after jQuery is loaded but before jQuery Mobile is loaded.

    + + + +
    +	$(document).bind('mobileinit',function(){
    +		$.mobile.selectmenu.prototype.options.nativeMenu = false;
    +	});
    +					
    +
    + +

    If there is a small number of options that will fit on the device's screen, it will appear as a small overlay with a pop transition.

    + +
    + + +
    + +

    If there is a select menu with too many options to show on the device's screen, the framework will automatically create a new "page" populated with a standard list view that contains all the options. This allows us to use the native scrolling included on the device for moving through a long list. The text inside the label is used as the title for this page.

    + + + + + +
    + + +
    + +

    Placeholder options

    +

    It's common for developers to include a "null" option in their select element to force a user to choose an option. If a placeholder option is present in your markup, jQuery Mobile will hide them in the overlay menu, showing only valid choices to the user, and display the placeholder text inside the menu as a header. A placeholder option is added when the framework finds:

    +
      +
    • An option with no value attribute (or an empty value attribute)
    • +
    • An option with no text node
    • +
    • An option with a data-placeholder="true" attribute. (This allows you to use an option that has a value and a textnode as a placeholder option).
    • +
    + +

    You can disable this feature through the selectmenu plugin's hidePlaceholderMenuItems option, like this:

    +
    +	
    +$.mobile.selectmenu.prototype.options.hidePlaceholderMenuItems = false;
    +	
    +	
    + +

    Here's a demo of various placeholder options:

    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + +

    Disabled options

    +

    jQuery Mobile will automatically disable and style option tags with the disabled attribute. In the demo below, the second option "Rush: 3 days" has been set to disabled.

    + +
    + + +
    + +

    Optgroup support

    +

    If a select menu contains optgroup elements, jQuery Mobile will create a divider & group items based on the label attribute's text:

    + +
    + + +
    + + +

    Multiple selects

    +

    If the multiple attribute is present in your markup, jQuery Mobile will enhance the element with a few extra considerations:

    + +
      +
    • A header element will be created inside the menu and display the placeholder text and a close button.
    • +
    • Clicking on an item inside the overlay menu will not close the widget.
    • +
    • A ghosted, unchecked icon will appear adjacent to each unselected item. When the item is selected the icon will change to a checkbox. Neither icon will appear inside a single select box.
    • +
    • Once 2+ items are selected, a counter element with the total number of selected items will appear inside the button.
    • +
    • The text of each selected item will appear inside the button as a list. If the button is not wide enough to display the entire list, it is truncated with an ellipses.
    • +
    • If no items are selected, the button's text will default to the placeholder text.
    • +
    • If no placeholder element exists, the default button text will be blank and the header will appear with just a close button. Because this isn't a friendly user experience, we recommended that you always specify a placeholder element when using multiple select boxes.
    • +
    + +
    + + +
    + +

    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.

    + +
    + + +
    + + + + +

    Styling with 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.

    + +
    + + +
    + + + +

    Refreshing a select

    + +

    If you manipulate a select via JavaScript, you must call the refresh method on it to update the visual styling. Here is an example:

    + +
    +var myselect = $("select#foo");
    +myselect[0].selectedIndex = 3;
    +myselect.selectmenu("refresh");
    +
    + + +
    + + + +
    + + + +
    + + + + diff --git a/docs/forms/selects/methods.html b/docs/forms/selects/methods.html new file mode 100644 index 00000000..2fe523c3 --- /dev/null +++ b/docs/forms/selects/methods.html @@ -0,0 +1,123 @@ + + + + + + jQuery Mobile Docs - Select methods + + + + + + + + + +
    + +
    +

    Select Menus

    + Home +
    + +
    +
    + +
    + +

    Select menus

    + + + +

    The select menu plugin has the following methods:

    + +
    + +
    close close an open select menu
    +
    +
    
    +$('select').selectmenu('close');			
    +				
    +
    + +
    enable enable a disabled select
    +
    +
    
    +$('select').selectmenu('enable');			
    +				
    +
    + +
    disable disable a select.
    +
    +
    
    +$('select').selectmenu('disable');			
    +				
    +
    + +
    open open a closed select menu
    +
    +
    
    +$('select').selectmenu('open');			
    +				
    +
    + +
    refresh update the custom select
    +
    + This is used to update the custom select to reflect the native select element's value.If the number of options in the select are different than the number of items in the custom menu, it'll rebuild the custom menu. Also, if you pass a true argument you can force the rebuild to happen. +
    
    +//refresh value			
    +$('select').selectmenu('refresh');
    +
    +//refresh and force rebuild
    +$('select').selectmenu('refresh', true);
    +				
    +
    + +
    + +
    +
    + + + +
    + + + +
    + + + + diff --git a/docs/forms/selects/options.html b/docs/forms/selects/options.html new file mode 100644 index 00000000..371efdaa --- /dev/null +++ b/docs/forms/selects/options.html @@ -0,0 +1,139 @@ + + + + + + jQuery Mobile Docs - Select options + + + + + + + + + +
    + +
    +

    Select Menus

    + Home +
    + +
    +
    + +
    + +

    Select menus

    + + + +

    The select menu plugin has the following options:

    + +
    + +
    corners boolean
    +
    +

    default: "true"

    +

    Applies the rounded corner class to add the theme button border-radius to the select button if set to true. This option is also exposed as a data attribute: data-corners="false"

    +
    $('select').selectmenu({ corners: "false" });
    +
    + +
    icon string
    +
    +

    default: "arrow-down"

    +

    Sets the icon for the select element from the icon set. This option is also exposed as a data attribute: data-icon="star"

    +
    $('select').selectmenu({ icon: "star" });
    +
    + +
    iconpos string
    +
    +

    default: "right"

    +

    Position of the icon in the select button. Possible values: left, right, none, notext. The notext value will display the select as an icon-only button with no text feedback. This option is also exposed as a data attribute: data-iconpos="left"

    +
    $('select').selectmenu({ iconpos: "left" });
    +
    + +
    iconshadow boolean
    +
    +

    default: "true"

    +

    Applies the icon drop shadow class to add the theme shadow style to the select button if set to true. This option is also exposed as a data attribute: data-iconshadow="false"

    +
    $('select').selectmenu({ iconshadow: "false" });
    +
    + +
    inline boolean
    +
    +

    default: "null" (false)

    +

    If set to true, this will make the select button act like an inline button so the width is determined by the feedback text inside. By default, this is null (false) so the select button is full width, regardless of the feedback content. Possible values: true, false. This option is also exposed as a data attribute: data-inline="true"

    +
    $('select').selectmenu({ inline: "true" });
    +
    + +
    nativeMenu boolean
    +
    +

    default: "true"

    +

    When set to true, clicking the custom-styled select menu will open the native select menu which is best for performance. If set to false, the custom select menu style will be used instead of the native menu. This option is also exposed as a data attribute: data-native-menu="false"

    +
    $('select').selectmenu({ nativeMenu: "false" });
    +
    + +
    shadow boolean
    +
    +

    default: "true"

    +

    Applies the drop shadow class to add the theme shadow style to the select button if set to true. This option is also exposed as a data attribute: data-shadow="false"

    +
    $('select').selectmenu({ shadow: "false" });
    +
    + +
    theme string
    +
    +

    default: null, inherited from parent

    +

    Sets the theme swatch color scheme for the select element. This is a single letter from a-z that maps to the swatches included in your theme. By default, a select will inherit the same swatch color as it's parent container if not explicitly set. This option is also exposed as a data attribute: data-theme="a"

    +
    $('select').selectmenu({ theme: "a" });
    +
    + +
    + +
    +
    + + + +
    + + + +
    + + + +