0

如上所述,jqm 自动完成功能最初运行良好,但是当触摸/单击建议的项目时,自动完成功能停止工作。但是,如果我刷新页面,它会再次起作用。有人可以告诉它是什么原因以及如何解决它?页面流:

  1. http://localhost/m/index.php: 自动完成效果很好

  2. 输入一些键,显示建议列表。触摸建议项目时,页面变为http://localhost/m/ABC。(ABC 是项目名称)。这个URL实际上被改写成http://localhost/m/index.php?q=ABC目的是为了有友好的URL。

  3. 现在,自动完成停止工作。
  4. 刷新页面http://localhost/m/ABC,然后自动完成功能再次起作用。

下面是我的脚本:

$("#mainPage").on("pageinit", function(e) {
console.log("Ready to bring the awesome.");
var sugList = $("#suggestions");

$("#searchField").on("input", function(e) {
    var text = $(this).val();
    if(text.length < 1) {
        sugList.html("");
        sugList.listview("refresh");
    } else {
        $.get("/m/suggest01.php", {search:text}, function(res,code) {
            var str = "";
            for(var i=0, len=res.length; i<len; i++) {
                str += "<li><a href=/m/"+res[i]["value"]+">"+res[i]["value"]+"</li>";
            }
            sugList.html(str);
            sugList.listview("refresh");
            sugList.trigger( "updatelayout");
            console.dir(res);
        },"json");
    }
});
});
4

0 回答 0