jQueryMobile listview with filter reveal, show items on click

倖福魔咒の 提交于 2019-12-19 04:49:18

问题


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 type. My data source is local (meaning the list is statically populated).

What I would like to do is to show all items without the need to enter any characters, but when the list itself gets the focus (and hide them when it's lost).

I know I could just jQuery all elements and do the show/hiding myself but I was wondering whether there was an out-of-the box solution available that I don't know of.


回答1:


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



来源:https://stackoverflow.com/questions/21001885/jquerymobile-listview-with-filter-reveal-show-items-on-click

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!