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.56k stars 1.66k forks source link

this.suggestions is undefined on form reload #794

Closed alessandrotesoro closed 4 years ago

alessandrotesoro commented 4 years ago

Hi there, thanks for your library. I've got a form that does some validation server side and if an error appears the page reloads and displays the error and it keeps all the values of the form preselected.

On page reload however, the following error shows up

TypeError: this.suggestions is undefined

jquery.autocomplete.js:639

Any suggestion on how to avoid this from happening? I'm guessing it happens because the input is pre-filled on reload and suggestions are loaded via ajax.

Thank you

tkirda commented 4 years ago

I think your guess is right. However when page reloads plugin should be reinitialized.

Based on error I can tell that it is trying to suggest, but suggestions array value is undefined. It is possible that when page reload you are not initializing it correctly. Because suggestions values come from the server if you are using serviceUrl endpoint.