aut*_*att 29 javascript css jquery-ui autocomplete
使用jquery ui 1.8尝试自动完成
除了ui菜单不在我的输入元素下面,而是在左上角,一切都有效.
有人遇到过这个问题吗?
这是我的HTML:
<div id="search">
<div id="searchFormWrapper">
<form method="post" name="searchForm" id="searchForm" action="/searchresults">
<label for="searchPhrase" id="searchFor">
Search for</label>
<input name="searchPhrase" id="searchPhrase" type="text" />
<label for="searchScope" id="searchIn">
in</label>
<select name="searchScope" id="searchScope">
<option value="">All Shops</option>
...
</select>
<input type="image" name="submitSearch" id="submitSearch" src="/images/buttons/search.gif"
alt="Search ..." />
</form>
<br class="clear" />
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
这是我的css:
#search
{
width:100%;
margin:0;
padding:0;
text-align:center;
height:36px;
line-height:36px;
background:#666 url(/images/interface/info_bar_bg.gif) repeat-x top left;
overflow:hidden;
font-size:12px;
}
#searchFormWrapper
{
width:520px;
height:36px;
overflow:hidden;
margin:auto;
padding:0;
}
label#searchFor
{
display:block;
float:left;
width:80px;
padding:0 5px 0 0;
margin:0 0 0 0;
text-align:right;
}
label#searchIn
{
display:block;
float:left;
width:20px;
padding:0 5px 0 0;
margin:0 0 0 0;
text-align:right;
}
#searchPhrase
{
display:block;
float:left;
width:120px;
margin:7px 0 0 0;
padding:0;
}
#searchScope
{
display:block;
float:left;
width:120px;
margin:7px 0 0 0;
padding:0;
}
#submitSearch
{
display:block;
float:left;
margin:7px 0 0 10px;
padding:0;
}
Run Code Online (Sandbox Code Playgroud)
这是我的javascript:
$(document).ready(function()
{
$("#searchPhrase").autocomplete(
{
source: "/search?json",
minLength: 2
});
});
Run Code Online (Sandbox Code Playgroud)
aut*_*att 35
哇噢.找到了罪魁祸首:
<script type="text/javascript" src="/scripts/jquery/132/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="/scripts/jquery/132/jquery-ui-1.8.custom.min.js"></script>
<script type="text/javascript" src="/scripts/jquery/100325/jquery.dimensions.js"></script>
<script type="text/javascript" src="/scripts/jquery/100325/jquery.tooltip.js"></script>
Run Code Online (Sandbox Code Playgroud)
不要包含jquery.dimensions.js.我认为它已经在jquery-ui.js ...无论如何,它解决了我的问题.
对于最新的jqueryUI,您现在需要包含jquery.ui.position.js
小智 12
我有一个类似的问题,在搜索后我发现我错过了一个JS来解决这个问题.如果有人因为确保要调用"jquery.ui.position.js"脚本而停止.
请参阅依赖项下的http://jqueryui.com/demos/autocomplete/:UI核心UI小组件UI位置