HTML Code -
<div class="input-group-btn">
<div id="custom-templates">
<input class="typeahead caret" id="cur1" name="cur1" onkeypress="getData()" class="form-control" style=" color: black;text-transform: uppercase;border: 0px;border-radius: 0px 5px 5px 0px;" aria-label="You Send" type="text" placeholder="BTC" value="BTC">
</div>
</div>
Typeahead JS Code -
var bestPictures = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: 'http://localhost/api/currency.php',
});
$('#custom-templates .typeahead').typeahead(null, {
name: 'best-pictures',
display: 'value',
source: bestPictures,
templates: {
empty: [
'<div class="empty-message">',
'unable to find any crypto currency',
'</div>'
].join('\n'),
suggestion: Handlebars.compile('<div><img src="{{image}}" class="svg"> <strong style="text-transform: uppercase;">{{value}}</strong> – {{year}}</div>')
}
});
Output -
As shown in the output, the image is added in the dropdown. Is there any way to display the icon as well, in the input box? Like when one clicks on BTC (see screenshot) the Image/ICON should be added in the inputbox along with the name.