jQuery Autocomplete: How to enable cache? -


This is my source code that uses the function to push the suggestion object:

 {Code> jquery (document) .ready (function ($) {var cache = {}; function partition (val) {return valple split (/, \ s * /);} remove the function last (word) {return partition ( Word) .pop ();} $ ("#ctags-input") .bind ("keydown", function (event) {if (event.keyCode === $ .ui.keyCode.TAB & amp; $ (This) .data ("auto integer"). Menuu.active) {event.preventDefault ();}}) .autocompatible ({source: function (r , Add) {var ctags_action = 'suggest_tags'; var term = req.term; if (in term cache) {add (cache [word]); return;} $ .getJSON (suggestTags.url +'? Callback =? And Action = '+ CTAG_Action, Rick, Function (data) {var Suggestion = []; $ (information, work (i, wal) {suggestions.push ({label: val.name, count: val.count})}} Cache [word] = suggestion; add (suggestion);})}} focus: function () {return false;}, select: function (event, ui) {var word = partition (this.value); rms .pop (); Terms.push (ui.item.value); Terms.push (""); This.value = terms.join (","); return false; }} .data ("autocloplete") ._render item = function (ul, item) {return $ ("
  • "). Data ("item.autocomplete" , Item) .append ("& lt; a & gt;" + item.label + "(" + item.count + ") & lt; / a & gt;") .appendTo (ul); }; });

    To add the ability of the cache, the jq UI site demo directly uses the feedback for the data:

      source: function (request, response) {Var term = request duration; If (word in cache) {response (cash [period]); Return; } LastXhr = $ .getJSON ("search.php", request, function (data, position, xhr) {cache [word] = data; if (xhr === last Xhr) {response (data);}}); }   

    How to implement this cash demo in my code? In the cache suggestions

      var Word = req.term; If (word in the cache) {add (cache [duration]); Return; } ... cache [word] = suggestion; (Suggestion) add;    

  • Comments

    Popular posts from this blog

    Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

    java - How not to audit a join table and related entities using Hibernate Envers? -

    mongodb - CakePHP paginator ignoring order, but only for certain values -