Django jQueryUI自动完成建议显示在输入字段外部
我已经在Django项目中使用jQueryUi设置了一个自动完成表单 自动完成工作正常。问题是,建议不会显示在我的表单下,而是显示在屏幕的右侧 我需要的建议,以出现在我的搜索字段下,因为它应该和显示只有10个第一产品匹配我的搜索 我的HTML:Django jQueryUI自动完成建议显示在输入字段外部,django,jquery-ui,autocomplete,Django,Jquery Ui,Autocomplete,我已经在Django项目中使用jQueryUi设置了一个自动完成表单 自动完成工作正常。问题是,建议不会显示在我的表单下,而是显示在屏幕的右侧 我需要的建议,以出现在我的搜索字段下,因为它应该和显示只有10个第一产品匹配我的搜索 我的HTML: <div class="ui-widget"> <input id="prod" class="form-control mr-sm-2" type="text&
<div class="ui-widget">
<input id="prod" class="form-control mr-sm-2" type="text" name="query" placeholder="">
</div>
My views.py:
$(function() {
$("#prod").autocomplete({
source: "/finder/search_auto",
select: function (event, ui) {
AutoCompleteSelectHandler(event, ui)
},
minLength: 2,
});
});$( "#prod" ).autocomplete({
position: { my : "right top", at: "right bottom" }
});
function AutoCompleteSelectHandler(event, ui)
{
var selectedObj = ui.item;
}
使用最新版本更新它:
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
这应该就够了。你有没有加入JqueryUI CSS?我说:
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>