spinners
spinners

Reputation: 2679

How do I use jquery autocomplete to display a different list after a selection is made?

So I have a textfield with an autocomplete attached to it working fine.

Here's what I want to happen:

  1. The user types some letters into the textfield
  2. The user is presented with the autocomplete suggestions list
  3. The user selects an item from the suggestion list
  4. The textfield is populated with the chosen item
  5. The user is immediately presented with another suggestion list composed from a specified array

Basically, after the user makes their selection I want to present them with boolean operators - "AND"/"OR". The textfield is for a search application. I want to facilitate users searching for multiple topics e.g. "Apples AND Bananas".

Thanks

Upvotes: 0

Views: 328

Answers (1)

Mandeep Jain
Mandeep Jain

Reputation: 2664

Use the select event of autocomplete

$( ".selector" ).on( "autocompleteselect", function( event, ui ) {
    // Write your code here
    // preferably update your source of tags. Like,
    // availableTags = [New tag1, New tag2, ...];
} );

Upvotes: 1

Related Questions