Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery Mobile Data Attributes

jQuery Mobile Data Attributes


jQuery Data Attributes

jQuery Mobile uses HTML5 data-* attributesto create a more touch-friendly and attractive appearance for mobile devices.

In the reference list below,values shown in boldare default values.


button

Deprecated since version 1.4. Use CSS classes instead. Hyperlinks with data-role="button". The button element, links in toolbars, and input fields are automatically rendered as button styles, no need to add data-role="button".

Data-attributes Value Description
data-corners true | false Specifies whether a button has rounded corners
data-icon Icon reference manual Specifies the icon of a button. Default is no icon.
data-iconpos left | right | top | bottom | notext Specifies the position of the icon
data-iconshadow true | false Specifies whether the button icon has a shadow
data-inline true | false Specifies whether a button is inline
data-mini true | false Specifies whether a button is small or regular size
data-shadow true | false Specifies whether a button has a shadow
data-theme Common Format Patterns (a-z) Specifies the theme color of a button
lamp To group multiple buttons, use a container with the data-role="controlgroup" attribute and data-type="horizontal|vertical" to specify whether to group the buttons horizontally or vertically.

Checkbox

Paired label and input with type="checkbox". They are automatically rendered as button styles, data-role is not required.

Data-attributes Value Description
data-mini true | false Specifies whether a checkbox is small or regular size
data-role none Prevents jQuery Mobile from rendering checkboxes as button styles
data-theme Common Format Patterns (a-z) Specifies the theme color of a checkbox
lamp To group multiple checkboxes, use a container with the data-role="controlgroup" attribute and data-type="horizontal|vertical" to specify whether to group the checkboxes horizontally or vertically.

Collapsible block

A header element followed by any HTML markup inside a container with data-role="collapsible".

Data-attributes Value Description
data-collapsed true | false Specifies whether the content is collapsed or expanded
data-collapsed-icon Icon reference manual Specifies the icon of the collapsible button. Default is "plus"
data-content-theme Common Format Patterns (a-z) Specifies the theme color of the collapsible content. Whether to add rounded corners to the collapsible content
data-expanded-icon Icon reference manual Specifies the icon of the collapsible button when the content is expanded. Default is "minus"
data-iconpos left | right | top | bottom Specifies the position of the icon
data-inset true | false Specifies whether the collapsible button is rendered with rounded corners and margins
data-mini true | false Specifies whether the collapsible button is small or regular size
data-theme Common Format Patterns (a-z) Specifies the theme color of the collapsible button

Collapsible sets

A collapsible content block inside a container with data-role="collapsible-set".

Data-attributes Value Description
data-collapsed-icon Icon reference manual Specifies the icon of the collapsible button. Default is "plus"
data-content-theme Common Format Patterns (a-z) Specifies the theme color of the collapsible button
data-expanded-icon Icon reference manual Specifies the icon of the collapsible button when the content is expanded. Default is "minus"
data-iconpos left | right | top | bottom | notext Specifies the position of the icon
data-inset true | false Specifies whether the collapsible block is rendered with rounded corners and margins
data-mini true | false Specifies whether the collapsible button is small or regular size
data-theme Common Format Patterns (a-z) Specifies the theme color of the collapsible set

Content

Deprecated in version 1.4, no longer supported after version 1.5. Use a container with data-role="content".

Data-attributes Value Description
data-theme Common Format Patterns (a-z) Specifies the theme color of the content.

Control group

A container with data-role="controlgroup".

or
container. Groups multiple button-style inputs of a single type (link-based buttons, radio buttons, checkboxes, select elements). For grouping form checkboxes and radio buttons, it is recommended to use a
element, use the
container with data-role="fieldcontain" to improve label styling.

Data-attributes Value Description
data-mini true | false Specifies whether the control group is small or regular size
data-type horizontal | vertical Specifies whether the control group is displayed horizontally or vertically

Dialogs

A container with data-role="dialog" or a link with data-rel="dialog".

Data-attributes Value Description
data-close-btn-text sometext Specifies the text of the dialog close button
data-dom-cache true | false Specifies whether to clear the jQuery DOM cache of individual pages (if set to true, you must manage the DOM yourself and test on all mobile devices)
data-overlay-theme Common Format Patterns (a-z) Specifies the overlay (background) color of the dialog page
data-theme Common Format Patterns (a-z) Specifies the theme color of the dialog page
data-title sometext Specifies the title of the dialog page

Enhancement

A container with data-enhance="false" or data-ajax="false".

Data-attributes Value Description
data-enhance **true **| false If set to "true" (default), jQuery Mobile automatically renders the page to make it more suitable for mobile devices. If set to "false", the framework will not render the page
data-ajax **true **| false Specifies whether to load pages via ajax

**Note:** data-enhance="false" must be used together with $.mobile.ignoreContentEnabled=true" to prevent jQuery Mobile from automatically rendering the page.

When $.mobile.ignoreContentEnabled is set to true, any links or form elements inside a data-ajax="false" container will be ignored by the framework's navigation features.


Field container

Deprecated after version 1.4 and no longer supported after version 1.5; class="ui-fieldcontain will be used instead". A container that wraps a label/form element pair with data-role="fieldcontain".


Fixed toolbar

A container with data-role="header" or data-role="footer" and the data-position="fixed" attribute.

Data-attributes Value Description
data-disable-page-zoom true | false Specifies whether the user can zoom the page
data-fullscreen true | false Specifies whether the toolbar is always fixed at the top or bottom
data-tap-toggle true | false Specifies whether the user can change the toolbar's visibility by clicking
data-transition slide | fade | none Specifies the transition effect when a click occurs
data-update-page-padding true | false Specifies whether the padding at the top and bottom of the page is updated when resize, transition, and "updatelayout" events occur (jQuery Mobile always updates padding when the "pageshow" event occurs)
data-visible-on-page-show true | false Specifies the visibility of the toolbar when the parent page is shown

Flip toggle switches

An element with data-role="slider" elements. These are automatically rendered as button styles, date-role is not required.

Data-attributes Value Description
data-icon Icon reference manual Specifies the icon of the select element. Default is "arrow-d"
data-iconpos left | right | top | bottom | notext Specifies the position of the icon
data-inline true | false Specifies whether the select element is inline
data-mini true | false Specifies whether the select element is small or regular size
data-native-menu true | false When set to false, it uses jQuery's own custom select menu (recommended if you want the select menu to look the same on all mobile devices)
data-overlay-theme Common Format Patterns (a-z) Specifies the theme color of jQuery's own custom select menu (used with data-native-menu="false")
data-placeholder true | false Can be set on the
data-role none Prevents jQuery Mobile from rendering the select element as a button style
data-theme Common Format Patterns (a-z) Specifies the theme color of the select element
lamp To group multiple select elements, use a container with the data-role="controlgroup" attribute and data-type="horizontal|vertical" to specify whether to group the select elements horizontally or vertically.

Slider

An input with type="range". These are automatically rendered as button styles, date-role is not required.

Data-attributes Value Description
data-highlight true | false Specifies whether the slider track is highlighted
data-mini true | false Specifies whether the slider is small or regular size
data-role none Prevents jQuery Mobile from rendering the slider control as a button style
data-theme Common Format Patterns (a-z) Specifies the theme color of the slider control (input, handle, and track)
data-track-theme Common Format Patterns (a-z) Specifies the theme color of the slider track

Text inputs & textareas

An input or textarea element with type="text|search|etc.". These are automatically rendered as button styles, date-role is not required.

Data-attributes Value Description
data-mini true | false Specifies whether the input is small or regular size
data-role none Prevents jQuery Mobile from rendering the input/textarea as a button style
data-theme Common Format Patterns (a-z) Specifies the theme color of the input field