diff options
author | Felix Nagel <info@felixnagel.com> | 2013-04-29 23:40:26 +0200 |
---|---|---|
committer | Felix Nagel <info@felixnagel.com> | 2013-04-29 23:40:26 +0200 |
commit | 6640925db2f326932bc7d2ef76f4cd96930e92bd (patch) | |
tree | cc45853ac7e22d55ca59de17156ea167ce6f14c8 /ui/jquery.ui.autocomplete.js | |
parent | f96ee5e0488e28445fc4ebcc254dfa10aad2b1c9 (diff) | |
parent | 5c0a6aaeb7fac32950ddc44870295d5983ece15d (diff) | |
download | jquery-ui-6640925db2f326932bc7d2ef76f4cd96930e92bd.tar.gz jquery-ui-6640925db2f326932bc7d2ef76f4cd96930e92bd.zip |
Merge branch 'master' into selectmenu
Diffstat (limited to 'ui/jquery.ui.autocomplete.js')
-rw-r--r-- | ui/jquery.ui.autocomplete.js | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index 28cfdf2fb..2f303ca6e 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -16,9 +16,6 @@ */ (function( $, undefined ) { -// used to prevent race conditions with remote data sources -var requestIndex = 0; - $.widget( "ui.autocomplete", { version: "@VERSION", defaultElement: "<input>", @@ -77,7 +74,6 @@ $.widget( "ui.autocomplete", { this._on( this.element, { keydown: function( event ) { - /*jshint maxcomplexity:15*/ if ( this.element.prop( "readOnly" ) ) { suppressKeyPress = true; suppressInput = true; @@ -142,7 +138,9 @@ $.widget( "ui.autocomplete", { keypress: function( event ) { if ( suppressKeyPress ) { suppressKeyPress = false; - event.preventDefault(); + if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) { + event.preventDefault(); + } return; } if ( suppressKeyPressRepeat ) { @@ -417,21 +415,24 @@ $.widget( "ui.autocomplete", { this.source( { term: value }, this._response() ); }, - _response: function() { - var that = this, - index = ++requestIndex; + _response: (function() { + var requestIndex = 0; - return function( content ) { - if ( index === requestIndex ) { - that.__response( content ); - } + return function() { + var index = ++requestIndex; - that.pending--; - if ( !that.pending ) { - that.element.removeClass( "ui-autocomplete-loading" ); - } + return $.proxy(function( content ) { + if ( index === requestIndex ) { + this.__response( content ); + } + + this.pending--; + if ( !this.pending ) { + this.element.removeClass( "ui-autocomplete-loading" ); + } + }, this ); }; - }, + })(), __response: function( content ) { if ( content ) { |