contactmatt
contactmatt

Reputation: 18600

jQuery Autocomplete - Display list of values on focus in IE

Previously I had asked this question and accepted the answer because it worked in Chrome. This answer, however, does NOT work in IE 8 or IE 9 (and probably earlier versions as well). What I mean by "doesn't work" is that in IE when selecting a value from the list, the menu should close, but it remains open. I assume this is because the input keeps its focus when selecting a value. How can I fix it in IE?

I created a jSFiddle to illustrate this (open it in IE).

$(document).ready(function() {
    $("#cityInput").autocomplete({
        minLength: 0,
        source: ['one', 'two', 'three', 'four', 'five']
    }).focus(function() {
        $(this).autocomplete("search", "");
    });
});​

Upvotes: 1

Views: 1656

Answers (1)

Andrew Whitaker
Andrew Whitaker

Reputation: 126042

Try returning false from the event handler:

$("#cityInput").autocomplete({
    minLength: 0,
    source: ['one', 'two', 'three', 'four', 'five']
}).focus(function () {
    $(this).autocomplete("search", "");
    return false;
});

Updated fiddle: http://jsfiddle.net/GxsEC/5/

Upvotes: 2

Related Questions