_typeaheadElem.typeahead({ minLength: 0, hint: false },
$.extend(true, {}, _defaultDataSetConfig,
{
name: 'find-people',
source: function (query, cb) {
if (query.length >= 3) {
var altSource = _bloodhound_peopleSearch.ttAdapter();
altSource(query, cb);
}
return;
},
templates: {
header: '
',
empty: "Sorry. No results found."
}
}),
$.extend(true, {}, _defaultDataSetConfig,
{
name: 'recent-people',
//Show all RPs all the time
source: function (query, cb) { return cb(RECENT_PEOPLE_ARRAY); },
templates: {
header: ''
}
})
);
/* @type {Typeahead} A reference to the actual Typeahead object */
var _typeahead = _typeaheadElem.data('ttTypeahead');
/*
This is to make Recent People open when the field gets focus and there is no input.
This relies on the typeahead minLength == 0 and hint == false.
This is a fix for ttTA v 0.10.2 which doesn't support a feature like this. Newer versions might.
*/
_typeaheadElem.focus(function() {
/* WARNING: This is hackery abusing non-public Typeahead APIs */
if (_typeaheadElem.val() === "") {
//Set the component's current query to something that won't match the input.
var input = _typeahead.input; //Reference to the TA Input class
input.query = "Recent People";
input._onInput("");
//If you turn on hints, you will need this.
//input.clearHint(); //Clear out any previous hints
}
});