jQueryMobile listview with filter reveal, show items on click

前端 未结 1 352
忘了有多久
忘了有多久 2021-01-07 14:28

I have a listview created with jqueryMobile using the data-filter reveal feature. This feature hides the list elements and shows those matching the entered characters as you

1条回答
  •  迷失自我
    2021-01-07 14:55

    There is no out-of-the box solution, however, you can do the following.

    When input is focused, set .listview( "option", "filterReveal", true ); and hide all list view items manually by adding ui-screen-hidden jQM class. When blurred, reverse the previous action.

    Note: filterReveal is deprecated in jQM 1.4.0 and will be removed in 1.5.0.

    var list = $("#list");
    
    $("input").on("focus", function () {
        $(this).val("");
        list.listview("option", "filterReveal", false);
        list.children().removeClass("ui-screen-hidden");
        list.listview("refresh");
    }).on("keydown", function () {
        list.listview("option", "filterReveal", true);
        list.children().addClass("ui-screen-hidden");
        list.listview("refresh");
    });
    

    Demo

    0 讨论(0)
提交回复
热议问题