twitter/bootstrap — Issue #2092: Typeahead doesn't support AJAX etc.
Author: gudbergur
Created: 2012-02-20 00:18:00+00:00
State: open

I was looking for ajax addition to Typeahead and found nothing that suited me so I conjured my own patch. The main object was to allow AJAX functionality but you can do a few additional things with it:

Pass a function to the "source" option, that does something asynchronously and when ready calls typeahead.process() with a list of strings or objects. This is ideal for AJAX.
Pass a function to the "source" option, returning a list of strings/objects
Pass a list of objects to the "source" option and use a new "property" option to define which property on the objects defines the value on which is looked up and appears in the input box.
Pass a function to a new "onselect" option, which calls the function with object/string when selected.

You can get it here with a few examples and a diff between official Typeahead and mine: https://gist.github.com/1866577

I didn't know where else to post this but these additions have helped me a lot in two projects and I wanted to share it and get some feedback.