JQuery Autocomplete close option when click outside

后端 未结 2 1530
长发绾君心
长发绾君心 2021-01-05 18:17

I would like to know if there\'s a way in JQuery Autocomplete, when is open the options if I click OUTSIDE the options box to select or click ESCAPE in the keyboard. It clos

2条回答
  •  醉梦人生
    2021-01-05 19:09

    I ran into the same problem. There is only one little thing you have to do. After calling the 'search' methdod, set the focus. The Esc and clicking outside the box will close the dropdown.

    I'm using the category subclass (http://jqueryui.com/demos/autocomplete/#categories) so my code looks like

      $( "#search" ).catcomplete('search');
      $( "#search" ).focus();
    

    I'm expecting it will work the same on the .autocomplete widget as well.

提交回复
热议问题