#

Navigation Search

- Accordion
- AJAX Navigation
- Autocomplete
- Buttons
- Checkboxes
- Collapsibles
- Controlgroup
- Filterable New
- Dialogs
- Fixed toolbars
- Flip switch, slider
- Flip switch New
- Footer toolbar
- Form elements
- Grids
- Header toolbar
- Icons New
- Links
- Listviews
- Loader
- Navbar
- Navbar, persistent
- Pages
- Panels
- Popup
- Radio buttons
- Select
- Select, custom
- Slider, single
- Slider, dual range
- Table, column toggle
- Table, reflow
- Text inputs & textarea
- Transitions
- Collapsibles
- Dynamic collapsible
- Controlgroups
- Dynamic controlgroup
- Filterable
- Filterable inside custom select
- Listviews
- Grid Listview
- Autodividers Linkbar
- Autodividers Selector
- Maps
- Google Maps & Geolocation
- Google Maps with List toggle
- Navigation
- Backbone and Require.js example
- Redirection with server-side support
- Panels
- Panel styling
- Open panel on swipe
- Popups
- Dynamic popup
- Popup arrow size
- Popup alignment
- Responsive Tables
- Reflow: Custom styles
- Reflow: Heading groups
- Column toggle: Customization options
- Column toggle: Heading groups
- Column toggle demo: Phone comparison
- Sliders
- Tooltip extension
- Swipe
- Swipe to navigate
- Swipe to delete list item
- Forms
- Why won't my CSS styles apply correctly to a widget?
- Updating the value of enhanced form elements does not work.
- My HTML 5 inputs look different across devices and browsers.
- My range or search inputs are being change to number/text.
- Sometimes my custom select shows as a popup other times its a dialog.
- Disabling a button does not work.
- Controls in my fixed header or footer are not responding or behave erratically.
- Pages
- Why aren't my scripts and styles loading?
- Why isn't DOM ready working for my scripts?
- How do I load a page?
- Why is only the first page of my multi page document loaded?
- I'm trying to pass query params to a page but it's not working?
- I'm trying to pass information via the hash but it's not working?
- I'm trying to use the application cache but it's not working.
- Content injected into a page is not enhanced.
- Triggering create on injected HTML does not work.
- How can I stop JQM from auto-enhancing an element?
- How can I stop JQM from enhancing a block of elements?
- How do I control page titles?
- How do I load a page?
- How do I turn off the automatic hiding of the url bar?
- Events
- How do I use touch and mouse events?
- Theme and styling
- How does theming work?
- Apps
- How do I need to configure PhoneGap/Cordova?

# Filterable API

The children of any element can be filtered by setting the attribute `data-filter="true"` on the element. By default, the text contained in each child is used for filtering, however, you also have the option of setting the attribute `data-filtertext` to a string value on any child that will be considered for filtering to associate custom filter text instead.

## Basic filter

The filter widget is based on and replaces the listview filter extension. Thus, you can set `data-filter="true"` on a listview to generate a filter for its list items.

Nevertheless, the way in which a filterable is constructed differs from the way the listview filter extension worked in one important regard: the text field for entering the search string is not provided. Instead, you can provide the text field in your markup and have the filterable make use of it by providing a selector that will retrieve the text field as the value of the filterable's `data-input` attribute. Add class `ui-filterable` to the `form` in which you wrap the search input or to the listview to have the framework adjust the margin between the text field and listview.

The deprecated behavior whereby the filterable injects a text field before the element whose children are to be filtered is retained for version 1.4.0 to help with the transition from the listview filter extension, however, it will be removed in 1.5.0.

- Acura
- Audi
- BMW
- Cadillac
- Ferrari

## Table filter

You are not limited to using filters on listviews. To create a filter for a table widget, set `data-filter="true"` on the table element to generate a filter for table rows.

Rank | Movie Title | Year | Rating | Reviews
--- | --- | --- | --- | ---
1 | Citizen Kane | 1941 | 100% | 74
2 | Casablanca | 1942 | 97% | 64
3 | The Godfather | 1972 | 97% | 87

## Controlgroup Filter

The filter widget can be used on other widgets, too. To filter a list of controlgroup buttons, declare `data-filter="true"` on the element that creates the controlgroup (Note that you can also use the `data-filtertext` attribute to declare the text string used for filtering the respective element.

Button 1 Button 2 Button 3 Button 4 Button 5

## Filter Select

The widget also works on `select` widgets by hiding options that do not match the filter text. To use a filter for `options`, declare the `data-filter` attribute on the select element.

## Filter Anything

The widget can be used for filtering on any element containing other elements, like a `div` containing `p` elements.

These Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam

tags nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam

Tags erat, sed diam voluptua. At vero eos et accusam et justo duo dolores

are et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est

Filterable Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur

## Filter Styling

The filter widget supports the same attributes as the previous listview extension. Use `data-filter-theme` to declare a specific theme for the text field (overriding inheritance). `data-filter-placeholder` allows you to customize the input's placeholder text. In addition, the filterable widget will synchronize options shared between the textinput widget and the widget whose children it filters to make sure that the value of the textinput widget options is the same as the value of the widget options. So, for example, if you set `data-inset="true"` on the listview, then the corresponding textinput widget will also be inset.

NOTE: This behavior is deprecated and will be removed in 1.5.0. The correct way forward is to provide the text field (or any other widget that emits the "change" signal) as part of the original markup and to pass a selector that will retrieve it to the filterable widget via the `data-input` attribute.

- Acura
- Audi
- BMW
- Cadillac
- Ferrari

## Filter Reveal

The filter reveal feature makes it easy to build a simple autocomplete with local data. When a filter has the `data-filter-reveal="true"` attribute, it will auto-hide all the list items when the search field is blank. The `data-filter-placeholder` attribute can be added to specify the placeholder text for the filter. If you need to search against a long list of values, we provide a way to create a filter with a remote data source.

- Apple
- Banana
- Cherry
- Cranberry
- Grape
- Orange

## Filter Custom Callback

As with the listview extension, you can provide custom callback functions to the filter or override the filter altogether on the `filterablebeforefilter` event. Please note that the filter has a delay of 250ms before the filter actually triggers. This prevents running the filtering function multiple times while the user is typing.

To set a custom filtering function that will become the new default for all filterable widgets, override the `filterCallback` option in the filterable widget prototype in a "mobileinit" signal handler:

    $.mobile.document.one( "mobileinit", function() {
    	$.mobile.filterable.prototype.filterCallback = function( index, searchValue ) {
    		// In this function the keyword "this" refers to the element for which the
    		// code must decide whether it is to be filtered or not.
    		// A return value of true indicates that the element referred to by the
    		// keyword "this" is to be filtered.
    		// Returning false indicates that the item is to be displayed.
    		//
    		// your custom filtering logic goes here
    	});
    });

To set a custom filtering function for a single filterable widget, set the `filterCallback` option:

    $.mobile.document.one( "filterablecreate", "#myFilterable", function() {
    	$( "#myFilterable" ).filterable( "option", "filterCallback", function( index, searchValue ) {
    		// The previous example explains the signature of the callback function.
    		//
    		// your custom filtering logic goes here.
    	});
    });

To override the filter altogether (for example when loading data server-side or from localStorage), bind to the `filterablebeforefilter` event.

    $( ".selector" ).on( "filterablebeforefilter", function( e, data ) {
    		var value;

    		e.preventDefault();
    		value = data.input.value;
    		// trigger own request to database
    	});
    });

## Pre-rendering

The filterable widget runs the filter a single time during startup to make sure the list of children reflects the value entered in the search input. You can avoid this step by specifying the `data-enhanced="true"` attribute. When set to true, the filterable will assume that you have correctly applied the class `ui-screen-hidden` to those children that should be initially hidden.

The filterable widget is able to use the search input whether or not the search input is itself pre-rendered. In the example below, both the search input and the filterable are pre-rendered.

Acura Renault Hyundai