jquery-ui autocomplete在模态框(model)中,出不来

知识点:在使用模态框中使用 jquery-ui autocomplete,无法显示下拉框的数据

参考博客:https://www.jianshu.com/p/3944693773ed

解决办法:在autocomplete中添加 appendTo

<body>
<html>

<div class="modal-body">

<form class="m-form m-form--fit m-form--label-align-right"  id="m-form-1">
    <label class="col-form-label col-lg-2 col-sm-12">
药品名称 <span style="color: #F00">*</span>
</label>
<input type="text" style="width: 120px; z-index: 1055;" onchange="test1(this)"
class="form-control m-input" placeholder="药品名称" id="rolename" autocomplete="off" >
</form>

</div>

<script>
function test1(){
debugger
var arr=["zhansan","lishi"];
$("#rolename").autocomplete({
source : arr,// 数据
appendTo:$("#m-form-1")
//m-form-1是from表单的id

});

}
</script>
</body>
</html>
 

 

posted @ 2019-01-10 19:09  shuaiflying  阅读(1079)  评论(0编辑  收藏  举报