Jos*_*hDG 5 jquery listview jquery-autocomplete jquery-mobile
嘿,所以我希望进行过滤搜索,以便输入两个搜索字母,相应的结果将显示在列表视图中.我无法像jqm listview一样加载整个列表,因为它太大了.有人可以告诉我如何做到这一点......它有点超出了我对API的理解范围.
我知道如何使用自动完成小部件进行jquery,但我希望将结果格式化为listview.所以一个文本框,然后在它下面的listview格式化结果,但只有在输入两个字母之后我才会喜欢它来显示结果,这样它就不会显示一个巨大的列表,这需要花费很长时间才能加载.
我假设你的调用返回 JSON:
$("#txtInput").change(function() {
var val = $(this).val();
if (val.length >= 2)
{
// Do Ajax call
$.ajax({
type: "POST",
dataType: "json",
contentType: "application/json; charset=utf-8",
url: '/SomeURL/',
data: "{'searchText': '" + val + '}',
success: function (data) {
$("#divListArea").empty();
var i;
for (i = 0; i < data.length; i++)
{
$("#divListArea").append("<div key=" + data[i].Id + ">" + data[i].SomeProperty + "</div>");
}
$("#divListArea div").each(function() {
$(this).click(function() [
// Do something
var id = $(this).attr('key');
});
});
},
complete: function () {
}
});
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2902 次 |
| 最近记录: |