Currently this feature is waiting to be implemented (along with a bunch of other callbacks), I have found a simple solution (which requires editing the core typeahead.js
library)
Step 1
Inside typeahead.js
find the following line (approx Line: 840
in v0.9.3
).
// Within Class DropdownView
renderSuggestions: function(dataset, suggestions) {
...
this.trigger("suggestionsRendered"); // Find this line! approx line: 840
...
}
Step 2
Change the above line to:
renderSuggestions: function(dataset, suggestions) {
...
this.trigger("suggestionsRendered", suggestions); // Pass "suggestions" var
...
}
Step 3
Finally in your HTML
page (or Javascript
file), use the following to attach the event
:
// When you initialize your typeahead, store it into a variable
$typeahead = $('#your-typeahead-input-id-or-class').typeahead({options});
// Access that elements data property, and attach the event to dropdownView
$typeahead.data('ttView').dropdownView.on('suggestionsRendered', function (evtObj) {
console.log(evtObj.type); // Holds the event type: "suggestionsRendered"
console.log(evtObj.data); // Holds results of filtered data: Object
console.log("suggestionsRendered event callback fired");
// Do your stuffs..
});