jQuery ui 自动完成和 jScrollPane
我正在尝试将 jQuery ui 自动完成组件与 jScrollPane 一起使用来自定义溢出滚动条
HTML:
<label>Tags</label>
<input type="text" class="input_autocomplete">
CSS:
ul.ui-autocomplete{
width: 200px;
max-height: 120px;
overflow: auto;
background: #FFFFFF;
border: 1px solid #CCCCCC;
}
ul.ui-autocomplete li{
line-height:29px;
height: 29px;
min-width: 100%;
border-bottom: 1px solid #FFFFFF;
background:#dcdcdc;
}
ul.ui-autocomplete li:nth-child(2n+1){
background:#ebebeb;
}
SCRIPT:
<script type="text/javascript">
$(function() {
var availableTags = ["ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme",
"cia cia",
"bu bu",
"ih ih ih"];
var api;
var autocomplete_init = false;
$( ".input_autocomplete" ).autocomplete({
source: availableTags,
open: function(){
if(!autocomplete_init){
$('ul.ui-autocomplete').addClass('scroll-pane');
api = $('.scroll-pane').jScrollPane().data('jsp');
autocomplete_init = true;
} else {
api.reinitialise();
}
}
});
});
</script>
第一次搜索可以,但是如果我关闭自动完成列表并尝试使用相同的研究重新打开,jScollPane 不会重新初始化。 我哪里错了?
感谢您的帮助
I'm trying to use jQuery ui autocomplete component with jScrollPane to customize the overflow scrollbar
HTML:
<label>Tags</label>
<input type="text" class="input_autocomplete">
CSS:
ul.ui-autocomplete{
width: 200px;
max-height: 120px;
overflow: auto;
background: #FFFFFF;
border: 1px solid #CCCCCC;
}
ul.ui-autocomplete li{
line-height:29px;
height: 29px;
min-width: 100%;
border-bottom: 1px solid #FFFFFF;
background:#dcdcdc;
}
ul.ui-autocomplete li:nth-child(2n+1){
background:#ebebeb;
}
SCRIPT:
<script type="text/javascript">
$(function() {
var availableTags = ["ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme",
"cia cia",
"bu bu",
"ih ih ih"];
var api;
var autocomplete_init = false;
$( ".input_autocomplete" ).autocomplete({
source: availableTags,
open: function(){
if(!autocomplete_init){
$('ul.ui-autocomplete').addClass('scroll-pane');
api = $('.scroll-pane').jScrollPane().data('jsp');
autocomplete_init = true;
} else {
api.reinitialise();
}
}
});
});
</script>
the first search is ok, but if I close the autocomplete list and try to reopen with the same research, jScollPane not reinitialize.
Where I wrong?
thanks for your help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将其添加到您的代码中。
add this to your code.