You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Paul,
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
$(document).ready(function(){
$('#idOfTheAutocompleteField').bind('blur',function(){
$(this).next().val($(this).val());
});
});
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.
The text was updated successfully, but these errors were encountered:
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.
See: lift/framework#892 (imported from http://www.assembla.com/spaces/liftweb/tickets/892)
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:
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.
The text was updated successfully, but these errors were encountered: