Skip to content

Instantly share code, notes, and snippets.

@jharding
Last active February 11, 2019 09:26
Show Gist options
  • Save jharding/9458762 to your computer and use it in GitHub Desktop.
Save jharding/9458762 to your computer and use it in GitHub Desktop.
<div id="prefetch">
<input class="typeahead" type="text" placeholder="Countries">
</div>
var countries = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.whitespace,
queryTokenizer: Bloodhound.tokenizers.whitespace,
// url points to a json file that contains an array of country names, see
// https://github.com/twitter/typeahead.js/blob/gh-pages/data/countries.json
prefetch: '../data/countries.json'
});
// passing in `null` for the `options` arguments will result in the default
// options being used
$('#prefetch .typeahead').typeahead(null, {
name: 'countries',
source: countries
});
@DarsheeMehta
Copy link

Any idea how to fetch an Apex controller method to get the data for prefetch and remote?

@geraldinepascal
Copy link

Hi, thank you for these examples very usefull .
I would like find words that begin by my input.
For example, I would like select only countries beginning by "O" and not countries with a "O".
Do you how can I do it?
thx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment