Great, thanks for the pointer , I will try that.
On Jul 3, 10:47 pm, Tom Worster <f...@thefsb.org> wrote: > On 7/2/09 5:49 AM, "gnjunge" <gju...@gmail.com> wrote: > > > > > Concerning Jörn Zaefferer autocomplete. > > > In many cases the autocomplete list is being filled with Key Value > > pairs, such as a list of FooBars with their name and id. Using the > > result function one would get the id, and drop it into a hidden field. > > > I want to allow users to either pick an existing FooBars from the > > list, or enter a new one if he cannot find a suitable one. But for > > that to work I need to know that the autocomplete box contains a > > custom item, with other words: an item that was not in the list. > > > The result event is only triggered whenever an item was picked from > > the list. > > > How would I go about implementing this. My starting point was to add > > code to the "blur" event of the autocomplete, yet I can't get enough > > information to see if the currentValue is from the list, or a custom > > entry. > > what i did was add a flag in the input's .data() called 'chosen'. i set the > flag in the input's .result() handler. i clear it on .change(), or on > .focus() if the input's value is an empty string. > > the flag can be read whenever to determine if the value in the field is > chosen from the suggestions or typed.