twitter/typeahead.js — pull request #494 by libliflin (2013-10-21 19:12:55+00:00)
Title: add oneSuggestionEvent

used in conjuction with repeat checking and setTimeout blur, enables
automatic selection.

pros: enables full auto-selection.
cons: uses private methods; does not handle multiple sources; event called on click as well as type complete; setTimeout( blur) needed to get rid of suggestion drop down.

```
typeahead
.on('typeahead:selected',selected_action)
.on('typeahead:autocompleted',selected_action)
.on('typeahead:oneSuggestionEvent',selected_action);

selected_action = function(event, datum){
if(datum.value === ac){
console.log("nothing changed, move along");
return;
}else{
ac = datum.value;
}
jQuery('.type-ahead-example').typeahead('setQuery', datum.value);
setTimeout(function(){
jQuery('.type-ahead-example').blur();}, 0);

// some ajax call

jQuery('.some-other-field').focus();
}
```