Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _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: '<h4 class="search-header">Search Results</h4>',
- 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: '<h4 class="search-header">Recent People</h4>'
- }
- })
- );
- /* @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
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement