can't get jquery autocomplete styled
I have the jquery autocomplete example working on a test page, but can't seem to get the dropdown list styled. It just shows up as an ordinary ul with li items (not the white background box with a list as in the example). I have tried this alone and with the redmond theme, any thoughts on what I might be doing wrong? I see the redmond stylesheets in firebug, so the page is loading them.
js (working)
$(document).ready(function() {
$("input").autocomplete({
source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"]
});
});
css/js includes
<script src="/public/javascripts/jquery-1.6.2.js'"></script>
<script src="/public/javascripts/jquery-ui-1.8.14.custom.min.js"></script>
<script src="/public/javascripts/ac.js"></script> // where the above js is
<script s开发者_StackOverflow社区rc="/public/javascripts/jquery.tools.min.js"></script>
<link rel="stylesheet" type="text/css" media="print" href="/public/stylesheets/redmond/jquery.ui.all.css"/>
here is the input:
<input name="searchString" type="text" class="searchbox ui-autocomplete" id="autocomplete"/>
(edit: added CSS, overlooked this when writing the question)
Download a theme and include the theme's CSS.
<link rel="stylesheet" href="/public/css/jquery-ui.css" type="text/css">
You can see the themes here, and just download them from the download page by selecting the theme you want in the right-hand bar..
Edit: It looks like you're using the old jQuery auto-complete plug-in which has been discontinued. You can try the following CSS for that if you wish. I STRONGLY recommend you use the jQuery UI autocomplete however.
/* Autocomplete styles */
.ac_results {
padding: 0px;
border: 1px solid black;
background-color: white;
overflow: hidden;
z-index: 99999;
}
.ac_results ul {
width: 100%;
list-style-position: outside;
list-style: none;
padding: 0;
margin: 0;
}
.ac_results li {
margin: 0px;
padding: 2px 5px;
cursor: default;
display: block;
/*
if width will be 100% horizontal scrollbar will apear
when scroll mode will be used
*/
/*width: 100%;*/
font: menu;
font-size: 12px;
/*
it is very important, if line-height not setted or setted
in relative units scroll will be broken in firefox
*/
line-height: 16px;
overflow: hidden;
}
.ac_loading {
/* loader image */
background: white url('indicator.gif') right center no-repeat;
}
.ac_odd {
background-color: #eee;
}
.ac_over {
background-color: #0A246A;
color: white;
}
Use below theme in your application and it should work (add it in your master page/template OR on the page where you implement auto-complete feature.)
jquery.ui.theme.css
精彩评论