jQuery UI autocomplete show results before search

我的未来我决定 提交于 2019-12-06 04:20:25

You should set the minLength option to 0. If you want results to appear as soon as the field is focused into, you could write a simple event handler to accomplish that:

$("input").autocomplete({
    source: /* source */,
    minLength: 0
}).on("focus", function () {
    $(this).autocomplete("search", '');
});

Example: http://jsfiddle.net/mLSjL/

Edit: If you want to show the suggestion list immediately, try showing it on the create event of the autocomplete widget:

$("input").autocomplete({
    source: /* source */,
    minLength: 0,
    create: function () {
        $(this).autocomplete("search", '');
    }
});

Example: http://jsfiddle.net/CVUWV/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!