aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorJörn Zaefferer <joern.zaefferer@gmail.com>2011-05-18 17:47:01 +0200
committerJörn Zaefferer <joern.zaefferer@gmail.com>2011-05-18 17:47:01 +0200
commit4f0f407df3f1808112148a3a488c7bb76b9583db (patch)
tree154b8008aacc2afb024d3f805a3cef55432453a4 /ui
parent92b0f6702a9408f4bd7d71ccca7e0e851d0efc6b (diff)
parentadb35572a9f9dad166b21632b79aae65a505f630 (diff)
downloadjquery-ui-4f0f407df3f1808112148a3a488c7bb76b9583db.tar.gz
jquery-ui-4f0f407df3f1808112148a3a488c7bb76b9583db.zip
Merge remote branch 'treyhunner/topic/autocomplete-pasting'
Diffstat (limited to 'ui')
-rw-r--r--ui/jquery.ui.autocomplete.js35
1 files changed, 25 insertions, 10 deletions
diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js
index 0e62ccfdb..f6573174a 100644
--- a/ui/jquery.ui.autocomplete.js
+++ b/ui/jquery.ui.autocomplete.js
@@ -47,7 +47,8 @@ $.widget( "ui.autocomplete", {
_create: function() {
var self = this,
doc = this.element[ 0 ].ownerDocument,
- suppressKeyPress;
+ suppressKeyPress,
+ suppressInput;
this.valueMethod = this.element[ this.element.is( "input" ) ? "val" : "text" ];
@@ -63,10 +64,12 @@ $.widget( "ui.autocomplete", {
.bind( "keydown.autocomplete", function( event ) {
if ( self.options.disabled || self.element.attr( "readonly" ) ) {
suppressKeyPress = true;
+ suppressInput = true;
return;
}
suppressKeyPress = false;
+ suppressInput = false;
var keyCode = $.ui.keyCode;
switch( event.keyCode ) {
case keyCode.PAGE_UP:
@@ -110,15 +113,8 @@ $.widget( "ui.autocomplete", {
self.close( event );
break;
default:
- // keypress is triggered before the input value is changed
- clearTimeout( self.searching );
- self.searching = setTimeout(function() {
- // only search if the value has changed
- if ( self.term != self._value() ) {
- self.selectedItem = null;
- self.search( null, event );
- }
- }, self.options.delay );
+ // search timeout should be triggered before the input value is changed
+ self._searchTimeout( event );
break;
}
})
@@ -150,6 +146,14 @@ $.widget( "ui.autocomplete", {
break;
}
})
+ .bind( "input.autocomplete", function(event) {
+ if ( suppressInput ) {
+ suppressInput = false;
+ event.preventDefault();
+ return;
+ }
+ self._searchTimeout( event );
+ })
.bind( "focus.autocomplete", function() {
if ( self.options.disabled ) {
return;
@@ -317,6 +321,17 @@ $.widget( "ui.autocomplete", {
}
},
+ _searchTimeout: function( event ) {
+ var self = this;
+ self.searching = setTimeout(function() {
+ // only search if the value has changed
+ if ( self.term != self.element.val() ) {
+ self.selectedItem = null;
+ self.search( null, event );
+ }
+ }, self.options.delay );
+ },
+
search: function( value, event ) {
value = value != null ? value : this._value();