Typeahead - Scrollable Dropdown Menu

Mick picture Mick · Nov 6, 2015 · Viewed 14.6k times · Source

Looks like the CSS isn't working for my Typeahead. I am trying to reproduce the Scrollable Dropdown Menu like on https://twitter.github.io/typeahead.js/examples

Here is my code:

JS

var productList = new Bloodhound({
            datumTokenizer: Bloodhound.tokenizers.obj.whitespace('PART_NO'),
            queryTokenizer: Bloodhound.tokenizers.whitespace,
            //Maybe I need a prefetch
           // prefetch: '../data/films/post_1960.json',
            remote: {
                url: 'getProducts/%QUERY',
                wildcard: '%QUERY'
            }
        });

        $('#scrollable-dropdown-menu .typeahead').typeahead(null, {
            name: 'PARTS',
            limit: 10,
            display: 'PART_NO',
            source: productList
        });

CSS

 #scrollable-dropdown-menu .tt-dropdown-menu {
            max-height: 150px;
            overflow-y: auto;
            background-color: red;
        }

I can't see where the .tt-dropdown-menu is?

Cheers,

Mick

Answer

David Brower picture David Brower · Jan 7, 2016

See this GitHub issue. There is an issue with the scrollable dropdown example.

Update your CSS to:

 #scrollable-dropdown-menu .tt-menu {
   max-height: 150px;
   overflow-y: auto;
   background-color: red;
 }