File tree Expand file tree Collapse file tree 1 file changed +15
-15
lines changed
Expand file tree Collapse file tree 1 file changed +15
-15
lines changed Original file line number Diff line number Diff line change 1616 */
1717( function ( $ , undefined ) {
1818
19- // used to prevent race conditions with remote data sources
20- var requestIndex = 0 ;
21-
2219$ . widget ( "ui.autocomplete" , {
2320 version : "@VERSION" ,
2421 defaultElement : "<input>" ,
@@ -416,21 +413,24 @@ $.widget( "ui.autocomplete", {
416413 this . source ( { term : value } , this . _response ( ) ) ;
417414 } ,
418415
419- _response : function ( ) {
420- var that = this ,
421- index = ++ requestIndex ;
416+ _response : ( function ( ) {
417+ var requestIndex = 0 ;
422418
423- return function ( content ) {
424- if ( index === requestIndex ) {
425- that . __response ( content ) ;
426- }
419+ return function ( ) {
420+ var index = ++ requestIndex ;
427421
428- that . pending -- ;
429- if ( ! that . pending ) {
430- that . element . removeClass ( "ui-autocomplete-loading" ) ;
431- }
422+ return $ . proxy ( function ( content ) {
423+ if ( index === requestIndex ) {
424+ this . __response ( content ) ;
425+ }
426+
427+ this . pending -- ;
428+ if ( ! this . pending ) {
429+ this . element . removeClass ( "ui-autocomplete-loading" ) ;
430+ }
431+ } , this ) ;
432432 } ;
433- } ,
433+ } ) ( ) ,
434434
435435 __response : function ( content ) {
436436 if ( content ) {
You can’t perform that action at this time.
0 commit comments