Using Twitter Typeahead.js Custom Event Triggers by Eric on February 1, 2020
Since Bootstrap dropped support for their typeahead they have since told people to use Twitter's typeahead.js. It has a lot of great features that I have covered in an older write up about Twitter Typeahead.js. In this post I wanted to go over the custom events that are triggered and how you can use them to get more out of Twitter Typehead. There are five triggers in the typeahead.js and you can tap into each of these to do what you'd like when these events are triggered. Below are those events and when they are triggered. • typeahead:initialized – Triggered after initialization. If data needs to be prefetched, this event will not be triggered until after the prefetched data is processed. • typeahead:opened – Triggered when the dropdown menu of a typeahead is opened. • typeahead:closed – Triggered when the dropdown menu of a typeahead is closed. • typeahead:selected – Triggered when a suggestion from the dropdown menu is explicitly selected. The datum for the selected sug...