corejavascript / typeahead.js

typeahead.js is a fast and fully-featured autocomplete library
https://typeahead.js.org/
MIT License
967 stars 231 forks source link

Is there an event for typeahead ready? on init? #117

Open razvaniacob opened 7 years ago

razvaniacob commented 7 years ago

I want to run a function when the plugin is attached to an input but I can't seem to find how to do this. Please help!

https://github.com/twitter/typeahead.js/issues/64#issuecomment-14267698

jlbooker commented 7 years ago

There's the typeahead:active event, but I'm not sure that's quite what you're looking for.

This is probably a feature request to add such an event.

bryanrasmussen commented 7 years ago

I guess you could fake it with a mutationObserver to catch when typeahead elements are added.

MushuPlatypus commented 7 years ago

Would be nice to have a 'typeahead:initialized' event firing when the control is setup.

A temporary fix could be to insert this at line 1488: $input.trigger("typeahead:initialized", 'initialized'); right after $input.data(keys.typeahead, typeahead);

nkitsul-cyframe commented 7 years ago

For v0.10.0, it looks like, you should add what is suggested in the previous after line 1718: $input.data(typeaheadKey, typeahead);