Closed sukiyanen85 closed 4 years ago
Autocomplete currently is triggered only when value changes. You may try this:
const instance = $('#autocomplete').autocomplete();
// Provide array of suggestions if not yet provided
instance.suggestions = [];
// Open suggestions:
instance.suggest();
Thank you for taking the time to reply, this is my code at the moment:
const instance = $('#from').autocomplete({
serviceUrl: '/autocomplete'
});
$('.autocomplete_location').click(function(){
if(! $('#from').val().length){
instance.suggestions = [];
instance.suggest();
}
});
When I click on the icon, it shows the following error on the console
Uncaught TypeError: instance.suggest is not a function
To get instance you need to call autocomplete()
without parameters. Otherwise it returns jQuery object.
I have an autocomplete input, and I want to show the user a default list of results when he click on the icon
Can't seem to find out how to achieve this through the documentation, any one have an idea?