Question

I'm about to do a cool auto complete field and am thinking of using Typeahead.js

I understand with Typeahead.js I can do custom html templates for the suggestions which is great.

But I'm wondering can I also render whatever html I like for the value that is chosen from the suggestions?

I want to display a little image alongside the value chosen.

Just wanted to check it can be done before I deep dive typeahead.js

Was it helpful?

Solution

I can't quite tell what you mean; perhaps you want to decorate the choice with an image after the choice has been made?

That said, you probably want to look at the "Custom Events" section of the docs. I suspect one of typeahead:cursorchanged, typeahead:selected or typeahead:autocompleted will help. As usual, your callback receives the event, from the event you can dig out whatever you need.

I wouldn't worry about a deep rabbit hole. It's a simple library, you'll probably be able to figure out fairly quickly if what you want is possible.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top