0

我有这样的过滤器列表视图:

   <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>

在过滤栏中,如果我按“第 01 周”或“1”搜索,我可以获得结果。它显示了结果。

但我的要求是,如果用户键入“01-05”,那么过滤器需要显示“01”到“05”的内容。(这意味着它需要显示列表的 1 到 5)。在这种情况下,我如何自定义过滤器来实现这一点?

有人帮我吗?提前致谢。

4

1 回答 1

3

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".

于 2012-08-02T06:36:00.483 回答