Search code examples
jquerytwitter-typeahead

Twitter TypeAhead show all results programmatically


I've been busting my head on this for a while now. There are other answers floating around SO and other sites saying that if I change the value of my input to something else, then back to my original value, that TypeAhead will display.

Nothing is working in my case.

I retrieve my results like so:

$(element).typeahead({
    hint      : true,
    highlight : true, // This is to bold words that match the query
    minLength : queryLength
}, {
    name      : "results",
    displayKey: "value",
    source    : bhResults.ttAdapter()
});

After which, I've tried to forcefully display a drop down with all the results like so:

    window.setTimeout(function () {
        $(element).typeahead('val', value);
        $(element).focus();
        $(element).trigger("input");
        $(element).val('mood');
    }, 1000);

However, nothing is working!


Solution

  • One of the github issues covers a workaround: https://github.com/twitter/typeahead.js/issues/798