Bootstrap Typeahead: Remove forced selection of first item

Paritosh Singh picture Paritosh Singh · Dec 26, 2012 · Viewed 9.5k times · Source

Hi I am using typeahead in twitter bootstrap. What I found here is that in autocomplete dropdown, it selects first option by default. My requirement is that initially it should have nothing selected, it goes to first option only when I press navigation key (up or down) or when I hover over it. Is it possibe using typeahead.

Answer

Artem Zaika picture Artem Zaika · Aug 27, 2015

To avoid selection by typeahead first option by default, I used parameter documented in official docs: autoSelect. By default it set to 'true'

My code:

$('#searchString', this.el).typeahead({
        source: function (query, process) {
            var q = '/autocompleteSearch?searchString=' + query;               

            return $.get(q, function (data) {
                return process(data);
            });
        },
        minLength: 3,
        autoSelect: false
    });