[jQuery] [autocomplete] hasFocus is bugged in certain cases in IE

[jQuery] [autocomplete] hasFocus is bugged in certain cases in IE


Hello,
I've observed this behaviour in IE7. Using Jörn Zaefferer autocomplete
plugin. If you reload/refresh the page and the focus is automagically
(a function of the browser) given to the autocomplete field the focus
event doesn't fire. Hence hasFocus is zero and if you start typing the
results are never displayed.
A workaround I have made (this might be a bit too simplistic?) is in
the event handler for the onkeypress/down event I've just added this
one line at the top:
hasFocus=1;
(expanded sample):
$input.bind(($.browser.opera ? "keypress" : "keydown") +
".autocomplete", function(event) {
hasFocus = 1;
// track last key pressed
lastKeyPressCode = event.keyCode;
switch (event.keyCode) {
//... and so on...
It seems reasonable to expect that if sometime is typing in the field
then it has focus. Debugging javascript in IE is just not fun :(