11

我的问题很清楚。

我正在使用 jquery 自动完成,但我不知道为什么它只显示消息:

9 results are available, use up and down arrow keys to navigate.

没有向我显示结果列表。

这是我的代码:

<p class="select-c">
     <label for="fcb">Location</label>
     <input id="fcb" name="fcb" type="text">                        
</p>


$("#fcb").autocomplete({
        source: function (request, response) {
            $.ajax({
                type: "GET",
                dataType: 'json',
                url: "../ws/city/" + request.term,
                async: true,
                success: function( data ) {
                    response( $.map( data, function( item,key ) {
                        return {
                            label: key,
                            value: item.id_town+"#"+item.id_province
                        }
                    }));
                },
                error: function (result) {
                    alert("Due to unexpected errors we were unable to load data");
                }
            });
        },
        minLength: 2
    });

结果如下:

在此处输入图像描述

可能是什么问题呢??

4

3 回答 3

13

只需检查您是否正在导入正确的 css 以更正列表渲染

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"/>
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    <link rel="stylesheet" href="/resources/demos/style.css" />

如果您还想删除该消息,请在源之后添加以下条目

$("#fcb").autocomplete({
    //your source info
   messages: {
        noResults: '',
        results: function() {}
    }
});
于 2013-08-03T21:25:42.910 回答
10

Check your CSS, maybe you are hiding the menu element. Try with:

.ui-autocomplete {
  z-index: 10000000;
}
于 2013-07-02T11:07:11.603 回答
10
  .ui-helper-hidden-accessible {
            display: none;
        }
于 2014-04-22T19:10:40.743 回答