Typeahead - Scrollable Dropdown Menu
Asked Answered
A

2

10

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

Adulterine answered 6/11, 2015 at 11:29 Comment(0)
E
18

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;
 }
Examination answered 7/1, 2016 at 16:20 Comment(0)
L
0

try this

document.addEventListener("keydown", function (e) {
document.getElementById(e.target.attributes['aria- 
           activedescendant'].value).scrollIntoView(true)});
Lupitalupo answered 10/11, 2018 at 6:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.