Anthony
Anthony

Reputation: 1685

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?

Upvotes: 5

Views: 8049

Answers (2)

Brooksie
Brooksie

Reputation: 31

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)

Upvotes: 3

sje397
sje397

Reputation: 41862

JQuery UI's autocomplete has a search method:

myAutocomplete.autocomplete('search', 'sometext');

Upvotes: 8

Related Questions