devbridge / jQuery-Autocomplete

Ajax Autocomplete for jQuery allows you to easily create autocomplete/autosuggest boxes for text input fields
https://www.devbridge.com/sourcery/components/jquery-autocomplete/
Other
3.57k stars 1.67k forks source link

Suggestions dissapear on "Enter" #806

Closed Carl-Wilhelm closed 3 years ago

Carl-Wilhelm commented 3 years ago

When i press enter on keyboard, all suggestions disappear, and i can not find a way to prevent this behavior. Do you have a solution for this?

Thanks.

Carl-Wilhelm commented 3 years ago

I found a solution to fix this. I used javascript to disable form submit on "enter" with this code:

$("selector").keypress(function(event){ var keycode = (event.keyCode ? event.keyCode : event.which); if (keycode == '13') { event.preventDefault(); event.stopPropagation(); return false; } });

Then i edited the jquery.autocomplete.js file by commenting out these lines: case keys.RETURN: if (that.selectedIndex === -1) { //that.hide(); //return; } that.select(that.selectedIndex); break;

I also commented out TAB behaviour, because i did not want that.

tkirda commented 3 years ago

Looks like you solved your issue. Closing this.