jquery ui autcomplete does not disapper with no result

Posted by mike on Stack Overflow See other posts from Stack Overflow or by mike
Published on 2010-05-08T18:24:02Z Indexed on 2010/05/08 18:28 UTC
Read the original article Hit count: 190

Filed under:
|

Hi,

I'm using jquery ui autocomplete with the following code:

$('#company').autocomplete({
    source: function(request, response) {
        var company_name = $('#company').val();
        $.ajax({
            type: 'post',
            url: 'http://new.admin.localhost/client/helper/lookup_company_name',
            cache: false,
            data: { company : company_name },
            dataType: 'json',
            success: function(data) {
                //alert(data);
                response($.map(data.companies, function(item) {
                    return {
                        label: item.company,
                        value: item.company
                    }
                }))
            }
        })
    },
    minLength: 2,
});

This works as expected... The problem is, if the first few chars match something and then you enter a char that should "break" any match, it just keeps the drop down in place with the results for the last matched char... make sense? Would this be something I needed to change in the script that returns the data or something in the jquery?

thanks!

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript