twitter/typeahead.js — pull request #515 by tellex (2013-11-12 01:19:20+00:00)
Title: Add refreshCache method and new event dropdownOpened.

Added refreshCache method. So if you have multiple datasets binded to a typehead and u need to change a particular dataset value simple call $(".input-box").typeahead("refreshCache",[{name:Dataset1, url: "New URL"}]); -> Is important to always add "[]" because refreshCache expects an array of objects. This function will find all dataset cached to the typeahead and walk trought the array to find the matching dataset.name then it will check which attributes values changed and replace the new ones , refresh the associated cache object, and reinitialize the typeahead.
If u wish to add an dataset to the already existent datasets simple add the property AddDataset to the passed object. example $(".input-box").typeahead("refreshCache",[{name:NewDataSetName, local: etcetc, AddDataset: true}])

I added an new event called typeahead:dropdownOpened the reason behind this is that if add a new refreshCache dataset i will reinitialize the typeahead and destroy previously DOM created object ... so if u have binded an event to a element in the displayed suggestions Box it will be lost.... the solution to this:
Once you created the typeahead add
$(".input-box").on("typeahead:dropdownOpened",function(){
$('.special-suggestion-button').bind('click',function(event){ alert("Custom function"); event.stopImmediatePropagation() } );
});
I do this because if u do $('.tt-dropdown-menu').on('suggestionsRendered',function()).... and call new method refreshCache i will reinitialize the whole DOM object and destroy .tt-dropdown-menu so... the binded "on" will be lost...

Hope you enjoy the new function , sorry for my bad grammar my native languaje is spanish....

Greetings from argentina!!!