Sunday, April 15, 2012

Jquery Mobile - Data Attribute reference


The jQuery Mobile framework uses HTML5 data- attributes to allow for markup-based initialization and configuration of widgets. These attributes are completely optional; calling plugins manually and passing options directly is also supported. To avoid naming conflicts with other plugins or frameworks that also use data- attributes, set a custom namespace by modifying the ns global option.

Button

Links with data-role="button". Input-based buttons and button elements are auto-enhanced, no data-rolerequired
data-cornerstrue | false
data-iconhome | delete | plus | arrow-u | arrow-d | check | gear | grid | star | custom | arrow-r | arrow-l | minus | refresh | forward | back | alert | info | search
data-iconposleft | right | top | bottom | notext
data-iconshadowtrue | false
data-inlinetrue | false
data-minitrue | false - Compact sized version
data-shadowtrue | false
data-themeswatch letter (a-z)
Multiple buttons can be wrapped in a container with a data-role="controlgroup" attribute for a vertically grouped set. Add the data-type="horizontal" attribute for the buttons to sit side-by-side.

Checkbox

Pairs of labels and inputs with type="checkbox" are auto-enhanced, no data-role required
data-minitrue | false - Compact sized version
data-rolenone (prevents auto-enhancement to use native control)
data-themeswatch letter (a-z) - Added to the form element

Collapsible

A heading and content wrapped in a container with the data-role="collapsible"
data-collapsedtrue | false
data-content-themeswatch letter (a-z)
data-iconposleft | right | top | bottom | notext
data-minitrue | false - Compact sized version
data-themeswatch letter (a-z)

Collapsible set

A number of collapsibles wrapped in a container with the data-role="collapsible-set"
data-content-themeswatch letter (a-z) - Sets all collapsibles in set
data-iconposleft | right | top | bottom | notext
data-minitrue | false - Compact sized version
data-themeswatch letter (a-z) - Sets all collapsibles in set

Content

Container with data-role="content"
data-themeswatch letter (a-z)

Dialog

Page with data-role="page" linked to with data-rel="dialog" on the anchor.
data-close-btn-textstring (text for the close button, dialog only)
data-dom-cachetrue | false
data-overlay-themeswatch letter (a-z) - overlay theme when the page is opened in a dialog
data-themeswatch letter (a-z)
data-titlestring (title used when page is shown)

Enhancement

Container with data-enhance="false" or data-ajax="false"
data-enhancetrue | false
data-ajaxtrue | false
Any DOM elements inside a data-enhance="false" container, save for data-role="page|dialog"elements, will be ignored during initial enhancement and subsequent create events provided that the$.mobile.ignoreContentEnabled flag is set prior to the enhancement (eg in a mobileinit binding).
Any link or form elements inside data-enhance="false" containers will be ignored by the framework's navigation functionality when $.mobile.ignoreContentEnabled is set to true.

Field container

Container with data-role="fieldcontain" wrapped around label/form element pair

Flip toggle switch

Select with data-role="slider", two options only
data-minitrue | false - Compact sized version
data-rolenone (prevents auto-enhancement to use native control)
data-themeswatch letter (a-z) - Added to the form element
data-track-themeswatch letter (a-z) - Added to the form element

Footer

Container with data-role="footer"
data-idstring (unique id, useful in persistent footers)
data-positionfixed
data-fullscreentrue (used in conjunction with fixed toolbars)
data-themeswatch letter (a-z)

Header

Container with data-role="header"
data-positionfixed
data-fullscreentrue (used in conjunction with fixed toolbars)
data-themeswatch letter (a-z)

Link

Links, including those with a data-role="button", and form submit buttons share these attributes
data-ajaxtrue | false
data-directionreverse (reverse page transition animation)
data-dom-cachetrue | false
data-prefetchtrue | false
data-relback (to move one step back in history)
dialog (to open link styled as dialog, not tracked in history)
external (for linking to another domain)
data-transitionslide | slideup | slidedown | pop | fade | flip

Listview

OL or UL with data-role="listview"
data-count-themeswatch letter (a-z)
data-divider-themeswatch letter (a-z)
data-filtertrue | false
data-filter-placeholderstring
data-filter-themeswatch letter (a-z)
data-insettrue | false
data-split-iconhome | delete | plus | arrow-u | arrow-d | check | gear | grid | star | custom | arrow-r | arrow-l | minus | refresh | forward | back | alert | info | search
data-split-themeswatch letter (a-z)
data-themeswatch letter (a-z)

Listview item

LI within a listview
data-filtertextstring (filter by this value instead of inner text)
data-iconhome | delete | plus | arrow-u | arrow-d | check | gear | grid | star | custom | arrow-r | arrow-l | minus | refresh | forward | back | alert | info | search
data-rolelist-divider
data-themeswatch letter (a-z) - can also be set on individual LIs

Navbar

A number of LIs wrapped in a container with data-role="navbar"
data-iconhome | delete | plus | arrow-u | arrow-d | check | gear | grid | star | custom | arrow-r | arrow-l | minus | refresh | forward | back | alert | info | search
data-iconposleft | right | top | bottom | notext
data-themeswatch letter (a-z) - can also be set on individual LIs

Page

Container with data-role="page"
data-add-back-btntrue | false (auto add back button, header only)
data-back-btn-textstring
data-back-btn-themeswatch letter (a-z)
data-close-btn-textstring (text for the close button, dialog only)
data-dom-cachetrue | false
data-fullscreentrue (used in conjunction with fixed toolbars)
Deprecated in 1.1 - use on header and footer instead.
data-overlay-themeswatch letter (a-z) - overlay theme when the page is opened in a dialog
data-themeswatch letter (a-z)
data-titlestring (title used when page is shown)

Radio button

Pairs of labels and inputs with type="radio" are auto-enhanced, no data-role required
data-minitrue | false - Compact sized version
data-rolenone (prevents auto-enhancement to use native control)
data-themeswatch letter (a-z) - Added to the form element

Select

All select form elements are auto-enhanced, no data-role required
data-iconhome | delete | plus | arrow-u | arrow-d | check | gear | grid | star | custom | arrow-r | arrow-l | minus | refresh | forward | back | alert | info | search
data-iconposleft | right | top | bottom | notext
data-inlinetrue | false
data-minitrue | false - Compact sized version
data-native-menutrue | false
data-overlay-themeswatch letter (a-z) - overlay theme for non-native selects
data-placeholdertrue | false - Add to the Option
data-rolenone (prevents auto-enhancement to use native control)
data-themeswatch letter (a-z) - Added to the form element
Multiple selects can be wrapped in a fieldset with a data-role="controlgroup" attribute for a vertically grouped set. Add the data-type="horizontal" attribute for the selects to sit side-by-side.

Slider

Inputs with type="range" are auto-enhanced, no data-role required
data-highlighttrue | false - Adds an active state fill on track to handle
data-minitrue | false - Compact sized version
data-rolenone (prevents auto-enhancement to use native control)
data-themeswatch letter (a-z) - Added to the form element
data-track-themeswatch letter (a-z) - Added to the form element

Text input & Textarea

Input type="text|number|search|etc." or textarea elements are auto-enhanced, no data-rolerequired
data-minitrue | false - Compact sized version
data-rolenone (prevents auto-enhancement to use native control)
data-themeswatch letter (a-z) - Added to the form element

No comments:

Post a Comment