简体   繁体   English

jQuery-autocomplete滚动问题

[英]jQuery-autocomplete scroll issue

I'm using rails3-jquery-autocomplete in my application. 我在我的应用程序中使用rails3-jquery-autocomplete I've faced the following issue: if you enter something in the input field so that autocomplete data gets displayed and scroll the page after that, the box with the autocomplete data isn't scrolled with the page. 我遇到了以下问题:如果您在输入字段中输入内容以显示自动填充数据并在此之后滚动页面,则自动填充数据框不会随页面滚动。 It stays at the same position. 它保持在同一个位置。

You can look at what i'm facing here . 你可以看看我在这里面对的是什么。 Note that this example isn't created by me, so i'm not sure the same jquery plugin is used here. 请注意,此示例不是由我创建的,因此我不确定此处是否使用了相同的jquery插件。 Nevertheless the issue is pretty the same. 然而问题是完全一样的。

add this to the css 将此添加到CSS

     .ui-autocomplete { 
       height: 200px;
       overflow-y: scroll;
       overflow-x: hidden;
     }

Probably you are missing appendTo-attribute from options to Autocomplete. 您可能缺少从自动填充选项的appendTo属性。 It defaults to body , but you probably want to have it your container div (hard to say exactly without seeing your code). 它默认为body ,但你可能想要它是你的容器div (很难说没有看到你的代码)。

See documents . 文件

But have you checked the scenario, after applying height and overflow for the result can't able to scroll through the list using keyboard down arrow, which can able to scroll using mouse. 但你有没有检查过这个场景,在应用高度和溢出后,结果无法使用键盘向下箭头滚动列表,这可以使用鼠标滚动。 If we use keyboard to scroll it keeping the scroll bar ideal and making the highlight value to traverse throughout the list. 如果我们使用键盘滚动它,保持滚动条理想,并使高亮值在整个列表中遍历。

I know this is old but I just fixed this in my own project by adding a CSS property of "position: fixed" to ".ui-autocomplete" in my project. 我知道这已经过时但我只是通过在我的项目中将“position:fixed”的CSS属性添加到“.ui-autocomplete”来修复我自己的项目。 Check it out here if u want: 34.212.191.181:3000. 如果你愿意,请在这里查看:34.212.191.181:3000。

P/s the page is in Vietnamese, just play with the search box in the nav bar :) P / s页面是越南语,只需使用导航栏中的搜索框:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM