Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to trigger autocomplete search event

I have jQuery autocomplete setup on an input box.

It is working fine.

However, I want to have a button that when clicked will trigger autocomplete as though the user type some text in the input. I would pass a specific string.

Any ideas on how I can do this?

like image 451
Anthony Avatar asked Dec 16 '10 05:12

Anthony


2 Answers

JQuery UI's autocomplete has a search method:

myAutocomplete.autocomplete('search', 'sometext');
like image 176
sje397 Avatar answered Nov 13 '22 10:11

sje397


This worked for where #inputID is a text input on which the autocomplete is attached.

$("#inputID").autocomplete('search');

Tested in FireFox and Chrome (Ubuntu 12.04 LTS)

like image 28
Brooksie Avatar answered Nov 13 '22 10:11

Brooksie