Just in case, if someone needs to use typeahead with a Kentico .json file:
using a file like:
{myKenticoSite}/rest/cms.country?format=json&columns=CountryName
(be aware... json can be case sensitive...)
<script type='text/javascript'>
$(window).load(function(){
var v01 = new Bloodhound({
limit: 10,
datumTokenizer: function (d) {
return Bloodhound.tokenizers.whitespace(d.value);
},
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: {
url: '{myKenticoSite}/rest/cms.country?format=json&columns=Countrydisplayname',
filter: function (v01) {
return $.map(v01.cms_countries[0].cms_country, function (myCountry) {
return {
value: myCountry.Countrydisplayname
};
});
}
}
});
// Initialize the Bloodhound suggestion engine
v01.initialize();
// Instantiate the Typeahead UI
$('.typeahead').typeahead(
{
hint: true,
highlight: true,
minLength: 1
},
{
//displayKey: 'value',
displayKey: function (f01) {
return f01.value;
},
source: v01.ttAdapter()
});
});
</script>
<div class="bs-example">
<input class="typeahead">
</div>