自动完成 - 可滚动下拉菜单

10
看起来我的Typeahead的CSS没有起作用。 我正在尝试复制https://twitter.github.io/typeahead.js/examples上的可滚动下拉菜单。

这是我的代码:

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;
        }

我看不到.tt-dropdown-menu在哪里?

谢谢,

Mick

2个回答

18

请查看GitHub问题页面。下拉列表出现滚动条问题。

请更新您的CSS代码:

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

0

试一下这个

document.addEventListener("keydown", function (e) {
document.getElementById(e.target.attributes['aria- 
           activedescendant'].value).scrollIntoView(true)});

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接