[英]How can I use a data-filter attribute on a listview that has multiple columns in jQuery/HTML?
I need to be able to search through a list of contacts in a jQuery Mobile site that I'm working on. 我需要能够在我正在处理的jQuery Mobile网站中搜索联系人列表。 It's formatted with the contacts name underneath the contacts image, and there are two columns of contacts,
ui-block-a
, and ui-block-b
, as such: 它使用联系人图像下方的联系人名称进行格式化,并且有两列联系人,
ui-block-a
和ui-block-b
,如下所示:
<div data-role="content" data-theme="c" class="ui-grid-b">
<ul data-role="listview" data-filter="true" data-inset="false">
<div class="ui-block-a">
<ul>
<li>
<a href="tel:0123456789"><img src="images/personMale.png" width="100"></a>
<p><b>Bar, Foo</b></p>
</li>
<li>
<a href="tel:0123456789"><img src="images/personMale.png" width="100"></a>
<p><b>Santor, George</b></p>
</li>
</ul>
</div>
<div class="ui-block-b">
<ul>
<li>
<a href="tel:0123456789"><img src="images/personMale.png" width="100"></a>
<p><b>Sebastian, John</b></p>
</li>
<li>
<a href="tel:0123456789"><img src="images/personMale.png" width="100"></a>
<p><b>Foo, Bar </b></p>
</li>
</ul>
</div>
</ul>
</div>
Currently, when you search for a specific name, instead of showing only the one contact, it shows the column that it's in- either ui-block-a
or ui-block-b
. 当前,当您搜索特定名称时,它不显示一个联系人,而是显示该列在
ui-block-a
或ui-block-b
。 Here's an example of it happening in jsfiddle . 这是jsfiddle中发生的示例 。 I've tried a more manual javascript approach with the
ul
s inside of ui-block-a
and ui-block-b
being the search target, but I basically run into the same problem. 我尝试了一种更手动的javascript方法,将
ui-block-a
和ui-block-b
内部的ul
ui-block-a
搜索目标,但是基本上遇到了相同的问题。 The actual project has around 10 contacts in each block/column. 实际项目在每个块/列中大约有10个联系人。 Any help is appreciated.
任何帮助表示赞赏。
I solved the issue by putting each contact into it's own ui-block-a
and ui-block-b
. 我通过将每个联系人放入自己的
ui-block-a
和ui-block-b
解决了该问题。 Minor formatting issues, but nothing a little CSS won't fix. 次要格式问题,但是一点CSS也无法解决。 Here's the updated jsfiddle.
这是更新的jsfiddle。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.