diff options
author | Scott González <scott.gonzalez@gmail.com> | 2010-07-20 12:10:58 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2010-07-20 12:10:58 -0400 |
commit | e4273ff6212040bd721184d661a39f046c4a461d (patch) | |
tree | f0c17b8f36c600eec926caa9dccab9eed2a06452 | |
parent | 2ed96cb0b8fbeaf8c72fb894242862cef81e84b2 (diff) | |
download | jquery-ui-e4273ff6212040bd721184d661a39f046c4a461d.tar.gz jquery-ui-e4273ff6212040bd721184d661a39f046c4a461d.zip |
Autocomplet: refactored handling of menu's selected event.
-rw-r--r-- | ui/jquery.ui.autocomplete.js | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index 602d5a545..7056e07f5 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -123,23 +123,20 @@ $.widget( "ui.autocomplete", { }, selected: function( event, ui ) { var item = ui.item.data( "item.autocomplete" ), - setValue = false; - if ( false !== self._trigger( "select", event, { item: item } ) ) { - // #5639 - if we set the value before setting focus - // the cursor will move to the beginning of the field in IE - setValue = true; - } - self.close( event ); + previous = self.previous; + // only trigger when focus was lost (click on menu) - var previous = self.previous; if ( self.element[0] !== doc.activeElement ) { self.element.focus(); self.previous = previous; } - self.selectedItem = item; - if ( setValue ) { + + if ( false !== self._trigger( "select", event, { item: item } ) ) { self.element.val( item.value ); } + + self.close( event ); + self.selectedItem = item; }, blur: function( event, ui ) { if ( self.menu.element.is(":visible") ) { |