Jqueryui autocomplete does not show parameters after cleaning

I use jqueryui autocomplete to display my text box with various options for the user.

In this case, I want the user to be able to select a value from the list and not enter another value.

I have achieved this:

$('#modelNo').autocomplete({ source: '/myurl/asdf' minLength: 2, delay: 300, change: function(event, ui) { if (!ui.item || ui.item.label == '') { $(this).val(''); } } }); 

Now it works very well, so when the user leaves the field and selects another, the field is cleared, but this causes another problem: if they type the same text again, autofill does not start, I assume I have forced it the state is somehow messed up, and perhaps he thinks the list has already been shown.

I looked at the list example on the jqueryui site, but it seemed rather complicated compared to what I am trying to achieve.

How to make autocomplete an updated list in this case?

+4
source share
1 answer

I seem to have fixed this by doing

  $(this).autocomplete("search", ""); 

after clearing the value, it would be interesting if there is a better way though.

0
source

Source: https://habr.com/ru/post/1411685/


All Articles