I'm changing over to the new autocomplete. In particular, I'm using autocomplete in a field where the user enters a city name, which must be in the list. After the entry, auto complete should save the equivalent numeric city ID in a hidden field, and populate a select box with the relevant zipcodes for that city. It should also only allow the user to enter cities which are in the database.
This works fine when the user enters the first few letters of the city and then selects one from the select list.
HOWEVER -- if the user enters the entire cityname without selecting, and tabs away to the next field, the "change" event is fired but the "select" event is not. Furthermore, the ui object for the "change" event is then null.
So in the change event, I could do another db call to the server to get the city name & id, and return an error if the city name doesn't exist, but of course I'd rather avoid that. Is there any clever way to do this?
Like, use the autocomplete widget to trigger a selection event on the entered from within the change event? Or any way to get access to the autocomplete's last dataset and search on the value (& change the case appropriately), get the matching id, etc? Or anything else?
I even tried using the autocomplete "search" method with the entered data, but that just re-displayed the same drop-down list with the one item.
This can't be such an unusual use case - to allow the user to type the entry and then process it as if it had been selected...