From 0ccc78698b55d5e1bc336bb754b546a9ad19ea5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 24 Sep 2010 16:49:10 -0400 Subject: [PATCH] Autocomplete: Handle IE firing focus events asynchronously. Fixes #6109 - Autocomplete Change event does not fire in IE. --- ui/jquery.ui.autocomplete.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index 176f81e0a..3dbcb9cf4 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -160,6 +160,12 @@ $.widget( "ui.autocomplete", { if ( self.element[0] !== doc.activeElement ) { self.element.focus(); self.previous = previous; + // #6109 - IE triggers two focus events and the second + // is asynchronous, so we need to reset the previous + // term synchronously and asynchronously :-( + setTimeout(function() { + self.previous = previous; + }, 1); } if ( false !== self._trigger( "select", event, { item: item } ) ) {