Permalink
Browse files

Autocomplete cache demo: Let the widget handle request synchronizatio…

…n. Fixes #8616 - Remote autocomplete example can leave pending request tracking out of sync.
  • Loading branch information...
1 parent 2c50b1b commit 5405a821b9d13daa11a2e66866fe8b16e7b68177 @scottgonzalez scottgonzalez committed Oct 2, 2012
Showing with 3 additions and 6 deletions.
  1. +3 −6 demos/autocomplete/remote-with-cache.html
@@ -18,8 +18,7 @@
</style>
<script>
$(function() {
- var cache = {},
- lastXhr;
+ var cache = {};
$( "#birds" ).autocomplete({
minLength: 2,
source: function( request, response ) {
@@ -29,11 +28,9 @@
return;
}
- lastXhr = $.getJSON( "search.php", request, function( data, status, xhr ) {
+ $.getJSON( "search.php", request, function( data, status, xhr ) {
cache[ term ] = data;
- if ( xhr === lastXhr ) {
- response( data );
- }
+ response( data );
});
}
});

0 comments on commit 5405a82

Please sign in to comment.