3gwebtrain
3gwebtrain

Reputation: 15293

jquerymobile how to make customized filter?

i have the list view with filter like this :

   <ul data-role="listview" data-filter="true">
            <li>Week 01</li>
            <li>Week 02</li>
            <li>Week 03</li>
            <li>Week 04</li>
            <li>Week 05</li>
            <li>Week 06</li>
            <li>Week 07</li>
            <li>Week 08</li>
            <li>Week 09</li>
            <li>Week 10</li>
        </ul>

in the filter bar, i can able to get the result if i search by "week 01" or "1". it show the result.

but my requirement is, if the user types like "01-05", then the filter need to show the content of "01" to "05". ( that means it need to show from 1 to 5 of the list). in this case how can i customize the filter to achieve this?

Any one help me? thanks in advance.

Upvotes: 0

Views: 1648

Answers (1)

Pablo
Pablo

Reputation: 2854

You will need to define filter function with property $.mobile.listview.prototype.options.filterCallback during mobileinit event, or after you have created the listview, with $("#mylist").listview('option', 'filterCallback', yourFilterFunction). The filter function has the format function( text, searchValue ), where text is the current li element, and searchValue is the text you wrote in the filter input.

You will find this information and more in the jQueryMobile docs, in the section "Search filter".

Upvotes: 3

Related Questions