It's because typeahead already loaded your data from prefetch url and stored it in localStorage
. At the time data is in localStorage
, prefetch is not invoked.
Try change cacheKey
prefetch option like below and reload the page. Prefetch will invoke because there is no data tied to the new cacheKey in localStorage
.
var engine = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: {
url: "stations.json",
cacheKey: "change here!"
}
});
You can also check local storage with chrome developer tools.
Try to delete local storage data and reload page. Prefetch will invoke.
To remove localStorage data before Bloodhound initialization makes its prefetch invoke at every initialization time.
localStorage.removeItem("YOUR CACHEKEY");
// Bloodhound initialization with YOUR CACHEKEY.
clearPrefetchCache()
before initialize()
is better, I think.