Skip to content

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

@d6y

Description

@d6y

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:


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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions