You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Svein Erik Løken <sv...@jacilla.no> on 2015/02/10 23:40:26 UTC

How to clear the autocomplete cache?

Search box on a map:

<input t:id="poiName" t:type="TextField" t:mixins="autocomplete"
autocomplete.maxSuggestions="autocompleteMmaxSuggestions"/>

I need to call Bloodhound.clearRemoteCache() in typeahead.js

Did not find out how to access the engine variable in autocomplete.js.



Temporary hack/workaround:

I added $field.data("engine", engine); to autocomplete.js

engine.initialize();
dataset = {
        name: spec.id,
        displayKey: _.identity,
        source: engine.ttAdapter()
      };
*      $field.data("engine", engine);*
      return $field.typeahead({
        minLength: spec.minChars
      }, dataset);
    };
    return exports = init;
  });



Now I can clear cache with:

var ttInput = $(this._searchField).find("input.tt-input");
ttInput.data('engine').clearRemoteCache();



I don't want to modify t5/core/autocomplete.js



Hope someone can help me with a better solution!