YUI3自动完成功能在顶部有图像 - 如何自动完成到顶部

时间:2012-09-01 19:58:48

标签: yui

我的自动YUI自动完成zindex已关闭。如何强制自动完成DIV到顶部。

enter image description here

下面我使用YUI的标准模板:

YAHOO.util.Event.onDOMReady(函数(){     YUI()。use(“autocomplete”,“autocomplete-filters”,“autocomplete-highlighters”,function(Y){             var inputNode = Y.one('#name'),                     tags = [                         “样式表”,                         'CSS3',                         'douglas crockford',                         'ECMAScript中',                         'HTML',                         'HTML5',                         “Java的,                         'JavaScript的',                         'JSON',                         'node.js的',                         '馅饼',                         “衣”                     ]                     lastValue ='';

        inputNode.plug(Y.Plugin.AutoComplete, {
                activateFirstItem: true,
                minQueryLength: 0,
                queryDelay: 0,
                source: tags,
                resultHighlighter: 'startsWith',
                resultFilters: ['startsWith']
        });

        // When the input node receives focus, send an empty query to display the full
        // list of tag suggestions.
        inputNode.on('focus', function () {
                inputNode.ac.sendRequest('');
        });

        // When there are new AutoComplete results, check the length of the result
        // list. A length of zero means the value isn't in the list, so reset it to
        // the last known good value.
        inputNode.ac.on('results', function (e) {
                if (e.results.length) {
                        lastValue = inputNode.ac.get('value');
                } else {
                        inputNode.set('value', lastValue);
                }
        });

        // Update the last known good value after a selection is made.
        inputNode.ac.after('select', function (e) {
                lastValue = e.result.text;
        });
});

});

1 个答案:

答案 0 :(得分:1)

简单地将z-index放在css中。通过JS设置曾经被允许,但从YUI 3.4.0开始,它是一个仅限CSS的标志(https://github.com/yui/yui3/blob/master/src/autocomplete/HISTORY.md).

相关的CSS是(根据需要调整你的z-index):

.yui3-aclist { z-index: 100; }

PS。,你的YAHOO。 line来自YUI2,因此非常奇特,绝对不是标准模板。

当调用YUI()。use(...)部分中的回调时,dom应该准备就绪。没有准备就绪。