jQuery autocomplete UI- I'd like it to start t

2020-01-31 04:03发布

jQuery autocomplete UI - I'd like to start the search "onfocus" and immediately show the list of choices when the user tabs or clicks into the search field without the user having to type anything.

The default behavior seems to requires the user to enter a character or a down arrow to start the ball rolling and start the search and get the values even when I set the number of character required to zero.


$( "#contact" ).autocomplete({
    source: 'remote.php',
    minLength: 0
});

thanks!

7条回答
家丑人穷心不美
2楼-- · 2020-01-31 04:39
$("#contact").focus(function() {
    if ($(this).val().length == 0) {
        $(this).autocomplete("search");
    }
});

Make sure your autocomplete's minLength is 0.

查看更多
登录 后发表回答