【发布时间】:2023-03-26 10:13:01
【问题描述】:
您好,我不明白 web 控制台中的错误是什么意思。
Uncaught TypeError: r.getClientRects is not a function jquery.min.js:2
我正在尝试基于我下载的引导主题在 laravel 中构建一个自动完成搜索表单。
它可以工作,但下拉菜单与文本框未对齐 我怀疑 JQuery 因为那个错误以及在我拥有的不同引导主题中它有效的事实 我的脚本链接如下
<link href="http://myurl.com/vendor/bootstrap/css/bootstrap.min.css"
rel="stylesheet">
<link href="http://myurl.com/vendor/fontawesome-free/css/all.min.css"
rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Varela+Round"
rel="stylesheet">
<link href="https://fonts.googleapis.com/css
rel="stylesheet">
<link href="http://myurl.com/css/grayscale.min.css" rel="stylesheet">
<script src='https://www.google.com/recaptcha/api.js'></script>
<script src="http://myurl.com/vendor/jquery/jquery.min.js"></script>
<script
src="http://myurl.com/vendor/bootstrap/js/bootstrap.bundle.min.js"> .
</script>
<script src="http://myurl.com/vendor/jquery-
easing/jquery.easing.min.js"></script>
<script src="http://myurl.com/js/grayscale.min.js"></script>
我的表格:
<form class="form-inline d-flex">
<input class="form-control autocomplete_txt input-lg flex-fill mr-0 mr-sm-2 mb-3 mb-sm-0"
type='text' data-type="EmpService" id='EmpService_1' name='EmpService[]' autocomplete="off" placeholder="looking for...">
<button type="submit" class="btn btn-primary mx-auto">Search</button>
<div class="col-xs-4 g-recaptcha" data-sitekey="6Lf9mW4UAAAAACtNJIuXY9VlCZ5kg0Ys7Y3ancH_"></div>
</form>
我的 Javascript:
$(document).on('focus','.autocomplete_txt',function(){
type = $(this).data('type');
if(type =='EmpService' )autoType='EmployeeService';
$(this).autocomplete({
minLength: 0,
source: function( request, response ) {
$.ajax({
url: "http://spanibox.com/searchajax",
dataType: "json",
data: {
term : request.term,
type : type,
},
success: function(data) {
var array = $.map(data, function (item) {
return {
label: item[autoType],
value: item[autoType],
data : item
}
});
response(array)
}
});
},
select: function( event, ui ) {
var data = ui.item.data;
id_arr = $(this).attr('id');
id = id_arr.split("_");
elementId = id[id.length-1];
$('#EmpService_'+elementId).val(data.name);
}
});
【问题讨论】:
-
这就是问题所在!
-
我如何投票给你的答案 - 我是新手
标签: javascript jquery