aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.autocomplete.js
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-01-31 22:04:09 -0500
committerScott González <scott.gonzalez@gmail.com>2011-01-31 22:04:09 -0500
commitcb8f5b7f2679ab5473229cac432f28c72521048c (patch)
tree60b63ec0b7f190832dcadef9e04a195985e61621 /ui/jquery.ui.autocomplete.js
parentbb857ddd8d6d4ac7620b49bf765352cd064494c0 (diff)
parenteffbb2c0ec2e60bea6ec5e5822ee52f8ea9e18bc (diff)
downloadjquery-ui-cb8f5b7f2679ab5473229cac432f28c72521048c.tar.gz
jquery-ui-cb8f5b7f2679ab5473229cac432f28c72521048c.zip
Merge branch 'master' into widget-events
Conflicts: ui/jquery.ui.widget.js
Diffstat (limited to 'ui/jquery.ui.autocomplete.js')
-rw-r--r--ui/jquery.ui.autocomplete.js15
1 files changed, 9 insertions, 6 deletions
diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js
index 1342f7648..594d59530 100644
--- a/ui/jquery.ui.autocomplete.js
+++ b/ui/jquery.ui.autocomplete.js
@@ -15,7 +15,11 @@
*/
(function( $, undefined ) {
+// used to prevent race conditions with remote data sources
+var requestIndex = 0;
+
$.widget( "ui.autocomplete", {
+ defaultElement: "<input>",
options: {
appendTo: "body",
delay: 300,
@@ -256,17 +260,16 @@ $.widget( "ui.autocomplete", {
url: url,
data: request,
dataType: "json",
- success: function( data, status, xhr ) {
- if ( xhr === self.xhr ) {
+ autocompleteRequest: ++requestIndex,
+ success: function( data, status ) {
+ if ( this.autocompleteRequest === requestIndex ) {
response( data );
}
- self.xhr = null;
},
- error: function( xhr ) {
- if ( xhr === self.xhr ) {
+ error: function() {
+ if ( this.autocompleteRequest === requestIndex ) {
response( [] );
}
- self.xhr = null;
}
});
};