neil
neil

Reputation: 387

jQuery UI autocomplete "no match" select

I've read through nearly all the posts on jQuery UI autocomplete, but I still can't figure this out.

If there isn't a match, I need to append an item to the list that says something like:

Create an entry for "Search Term Being Entered"

so it can be selected and I can run a function to deal with a new entry.

The problem I'm having is figuring out which event I need to hook into to update the menu and list.

Upvotes: 1

Views: 6443

Answers (2)

jk.
jk.

Reputation: 14435

This question may point you in the right direction:

Detecting no results on jQuery UI autocomplete

Be sure to look at the fiddle in Andrew's answer:

http://jsfiddle.net/andrewwhitaker/VBTGJ/

Upvotes: 2

Halcyon
Halcyon

Reputation: 57721

Wouldn't the server normally decide if the user entered a 'new item'?

I'm just making some basic assumptions here about your environment. The auto-complete list comes from some MySQL data. So the server should know if a term is new. Never trust user input from the client.

An autocomplete UI is not a way to force a certain input, it's merely a tool for the user to reuse existing or common values. The actual interpretation should happen on the server.

Upvotes: 0

Related Questions