Autocomplete() should have option to allow user to enter their own value #892

indrajitr opened this Issue Feb 12, 2011 · 4 comments

4 participants

Lift Web Framework member

The Autocomplete user allows the user to start typing, then select any of a popped up list of strings, and have the selected string passed to a function at submit time.

However, if the user types their own value, instead of choosing from the list, the string "" is passed to the specified function at submit time. This is right for some apps (where only the choices to be completed from are valid), but wrong for others (where the popped up completions are only suggestions).

The following javascript, from Mads Jensen, can be manually added to the page to fix this behavior:

Am I correct in assuming that what you want is to be able to submit a value that isn't part of the drop-down box? If this is the case you can fix it with a bit of javascript. In a javascript somew\
here that you load on the page with the form put this


Hope that helps,
Mads Hartmann Jensen

There should be a way to make this happen automatically (especially as this code is JQuery-specific). I'm not sure which behavior should be the default.


[[file:do2WDIrs4r4lmSeJe5cbLA]]: patch to AutoComplete, to add a blur event


I run into the same problem. See discussion [[url:|here]]

It is even worse. As it seems, the only time the value of the hidden field is updated - this is the value transmitted back to the server - is when something is selected in the drop down list.

If the user types something into what looks like a text field, this value is not sent to the server, but the value last selected from the list.

This could lead to the following situation: a user selects an article from the list, but then decides to delete the entry. The text field is now empty, but the last selection is sent to the server as value of that input field.

This behavior is, well, unexpected - under any circumstance.

The above patch (against eff1153bc8638218951c8fe3a70a9bad77c4b471 (2.2 final)) adds a blur event that copies the value into the hidden field when the autocomplete widget looses focus (thanks to info from Sergey Andreev).

It is the same functionality as the above snippet, but automatically generated.

Lift Web Framework member

Moved to Widgets module: liftmodules/widgets#4

@d6y d6y closed this Apr 23, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment