JQuery Autocomplete - caching is no longer an option?

Using jQuery Autocomplete, according to the docs, you should do the following for caching:

<script> $(function() { var cache = {}, lastXhr; $( "#birds" ).autocomplete({ minLength: 2, source: function( request, response ) { var term = request.term; if ( term in cache ) { response( cache[ term ] ); return; } lastXhr = $.getJSON( "search.php", request, function( data, status, xhr ) { cache[ term ] = data; if ( xhr === lastXhr ) { response( data ); } }); } }); }); </script> 

Wasn't there a caching option? Thanks

+7
source share
1 answer

Caching for jQueryUI autocomplete has never been an option.

For jQuery autocomplete, there was a cacheLength option (Jörn Zaefferer is now deprecated for plugin autocomplete).

In a guide to migrating from autocomplete to autocomplete -> jQueryUI, Jörn mentions the following:

cacheLength: Now there is no built-in caching support, but it is very simple to implement it yourself, as shown Remote with caching demo .

If you often use the caching implementation, you can wrap the functionality in another plugin that encapsulates it.

+9
source

All Articles