]> source.dussan.org Git - jquery-ui.git/commitdiff
Autocomplete: Don't handle remote data if it's not the most recent request. Fixes...
authorScott González <scott.gonzalez@gmail.com>
Tue, 24 Aug 2010 13:14:44 +0000 (09:14 -0400)
committerScott González <scott.gonzalez@gmail.com>
Tue, 24 Aug 2010 13:14:44 +0000 (09:14 -0400)
ui/jquery.ui.autocomplete.js

index 940d41adfdab16f7157f99193963d1bf3c8de4ca..6b19c440163d238a5af04677861b66d2d8111cfe 100644 (file)
@@ -210,7 +210,8 @@ $.widget( "ui.autocomplete", {
        },
 
        _initSource: function() {
-               var array,
+               var self = this,
+                       array,
                        url;
                if ( $.isArray(this.options.source) ) {
                        array = this.options.source;
@@ -220,7 +221,11 @@ $.widget( "ui.autocomplete", {
                } else if ( typeof this.options.source === "string" ) {
                        url = this.options.source;
                        this.source = function( request, response ) {
-                               $.getJSON( url, request, response );
+                               self.xhr = $.getJSON( url, request, function( data, status, xhr ) {
+                                       if ( xhr === self.xhr ) {
+                                               response.apply( this, arguments );
+                                       }
+                               });
                        };
                } else {
                        this.source = this.options.source;