jQuery Mobile List View
- Previous Page jQuery Mobile Grid
- Next Page jQuery Mobile List Content
jQuery Mobile List View
List views in jQuery Mobile are standard HTML lists: ordered lists (<ol>) and unordered lists (<ul>).
To create a list, add the data-role="listview" attribute to the <ol> or <ul> elements. To make these items clickable, specify a link in each list item (<li>):
Example
<oldata-role="listview"
> <li><a href="#">List Item</a></li> </ol> <uldata-role="listview"
> <li><a href="#">List Item</a></li> </ul>
To add rounded corners and margins to the list, use the data-inset="true" attribute:
Example
<ul data-role="listview" data-inset="true"
>
Tip:By default, list items in the list are automatically converted to buttons (no need for data-role="button").
List Dividers
List dividers (List Dividers) are used to organize and group items into categories/sections.
To specify list dividers, add the data-role="list-divider" attribute to the <li> element:
Example
<ul data-role="listview">
<li data-role="list-divider"
>Europe</li>
<li><a href="#">France</a></li>
<li><a href="#">Germany</a></li>
</ul>
If your list is in alphabetical order (such as a contact list), jQuery Mobile automatically adds appropriate dividers by setting the data-autodividers="true" attribute on the <ol> or <ul> elements:
Example
<ul data-role="listview" data-autodividers="true"
>
<li><a href="#">Adam</a></li>
<li><a href="#">Angela</a></li>
<li><a href="#">Bill</a></li>
<li><a href="#">Calvin</a></li>
...
</ul>
Tip:The data-autodividers="true" attribute creates dividers by capitalizing the first letter of the list item text.
Search Filter
To add a search box to the list, use the data-filter="true" attribute:
Example
<ul data-role="listview" data-filter="true"
</ul>
By default, the text in the search box is "Filter items...".
To modify the default text, please use the data-filter-placeholder attribute:
Example
<ul data-role="listview" data-filter="true" data-filter-placeholder="Search Name"
>
More Examples
- Read-only List
- How to create a list without links (not buttons, not clickable).
- Previous Page jQuery Mobile Grid
- Next Page jQuery Mobile List Content