带有过滤器显示的

带有过滤器显示的

本文介绍了带有过滤器显示的 jQueryMobile 列表视图,单击时显示项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我使用 jqueryMobile 使用数据过滤器显示功能创建了一个列表视图.此功能隐藏列表元素并在您键入时显示与输入的字符匹配的元素.我的数据源是本地的(意味着列表是静态填充的).

我想做的是在不需要输入任何字符的情况下显示所有项目,但是当列表本身获得焦点时(并在丢失时隐藏它们).

我知道我可以只对所有元素使用 jQuery 并自己进行显示/隐藏,但我想知道是否有我不知道的现成解决方案.

解决方案

没有现成的解决方案,但是,您可以执行以下操作.

input focused 时,设置 .listview( "option", "filterReveal", true ); 并隐藏所有列表视图项手动添加 ui-screen-hidden jQM 类.当模糊时,反转之前的动作.

注意:filterReveal 在 jQM 1.4.0 中已被弃用,并将在 1.5.0 中移除.

var list = $("#list");$("输入").on("焦点", function () {$(this).val("");list.listview("option", "filterReveal", false);list.children().removeClass("ui-screen-hidden");list.listview("刷新");}).on("keydown", function () {list.listview("option", "filterReveal", true);list.children().addClass("ui-screen-hidden");list.listview("刷新");});

演示

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.

解决方案

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");
});

这篇关于带有过滤器显示的 jQueryMobile 列表视图,单击时显示项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 20:47