Javascript 未捕获的类型错误:$(...).tooltip 不是函数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41961708/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Uncaught TypeError: $(...).tooltip is not a function
提问by Amadeu Cabanilles
I have a project based in Spring Web model-view-controller (MVC) framework. The version of the Spring Web model-view-controller (MVC) framework is 3.2.8 deployed on a WebLogic Server Version: 12.1.2.0.0
我有一个基于 Spring Web 模型-视图-控制器 (MVC) 框架的项目。部署在 WebLogic Server 上的 Spring Web 模型-视图-控制器 (MVC) 框架的版本为 3.2.8 版本:12.1.2.0.0
I have this error loading 1 JSP
加载 1 个 JSP 时出现此错误
Uncaught TypeError: $(...).tooltip is not a function
未捕获的类型错误:$(...).tooltip 不是函数
This is everything I load and I checked 1 by 1 and all of them are loaded
这是我加载的所有内容,我一一检查,所有内容都已加载
<link href="/tdk/styles/bootstrap.css" type="text/css" rel="stylesheet">
<link href="/tdk/styles/admin.css" type="text/css" rel="stylesheet">
<link href="/tdk/styles/jquery.dataTables.css" type="text/css" rel="stylesheet">
<link href="/tdk/styles/dataTables.bootstrap.css" type="text/css" rel="stylesheet">
<link href="/tdk/styles/slides.css" type="text/css" rel="stylesheet">
<script src="/tdk/scripts/jquery.min.js" type="text/javascript"></script>
<script src="/tdk/scripts/bootstrap.js" type="text/javascript"></script>
<script src="/tdk/scripts/jquery.dataTables.js" type="text/javascript"></script>
<script src="/tdk/scripts/dataTables.bootstrap.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js" type="text/javascript"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('[data-toggle="tooltip"]').tooltip();
var selected = [];
var table = $('#example').DataTable({
"dom": '<"top">rt<"bottom"lp><"clear">',
"autoWidth": false,
"paging": false,
"scrollX": false,
"scrollY": 300,
"scrollCollapse": true,
"rowCallback": function(row, data) {
if ($.inArray(data.DT_RowId, selected) !== -1) {
$(row).addClass('selected');
}
},
"columnDefs": [{
"targets": 'nosort',
"orderable": false
}, ]
});
$('#example tbody').on('click', 'input', function() {
$(this).closest("tr").toggleClass('selected');
if ($(this).is(':checked')) {
var theNameOfSelectedProduct = $(this).closest("tr").find("td.productname").text();
$('#selecteddevices').val($('#selecteddevices').val() + " " + theNameOfSelectedProduct);
$('#actions4devices button').removeAttr("disabled");
} else {
var theNameOfSelectedProduct = $(this).closest("tr").find("td.productname").text();
$('#selecteddevices').val($('#selecteddevices').val().replace(theNameOfSelectedProduct, ""));
if ($('#selecteddevices').val().trim().length == 0) {
$('#actions4devices button').not('.pull-right').attr("disabled", "disabled");
}
}
});
$('#refusedevicesButtonId').on('click', function() {
$('#theRefuseFile').show();
});
});
</script>
回答by Patrick Moore
Can we see where you're using $.tooltip()? It's possible that it occurs somewhere before the jQuery UI embed line. So try re-arranging your script includes so jQuery is first, jQuery UI is second, then along through the rest.
我们可以看看你在哪里使用$.tooltip()吗?它可能发生在 jQuery UI 嵌入行之前的某个地方。因此,请尝试重新安排您的脚本包含,因此 jQuery 是第一位的,jQuery UI 是第二位的,然后是其余的。
<script src="/tdk/scripts/jquery.min.js" type="text/javascript"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="/tdk/scripts/bootstrap.js" type="text/javascript"></script>
<script src="/tdk/scripts/jquery.dataTables.js" type="text/javascript"></script>
<script src="/tdk/scripts/dataTables.bootstrap.js" type="text/javascript"></script>
Hard to know without seeing your full code and knowing which files contains your calls to $.toolTip().
如果不查看完整代码并且不知道哪些文件包含您对$.toolTip().
One other quick attempt would be to substitute jQueryfor $where you're using, i.e.:
另外一个快速的尝试将替换jQuery为$你使用在哪里,即:
$(".tips").toolTip()
$(".tips").toolTip()
would become:
会成为:
jQuery(".tips").toolTip()
jQuery(".tips").toolTip()
回答by nifitovich
It's probably due to the version of jQuery. At least it was me and I solved this problem like this. I was using jQuery 3.3.1. The problem was solved when I changed the django to 1.10.3. Add this,
这可能是由于 jQuery 的版本。至少是我,我像这样解决了这个问题。我使用的是 jQuery 3.3.1。当我将 django 更改为 1.10.3 时,问题解决了。添加这个,
http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js
http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js
It needs work.
它需要工作。
回答by Leo
Be aware that jquery-uihas its own .tooltip() function and Bootstrapdoes too.
请注意jquery-ui有自己的 .tooltip() 函数,Bootstrap也有。
Try to reorder your js files like
尝试重新排序您的 js 文件,例如
<script src="/tdk/scripts/jquery.min.js" type="text/javascript"></script>
<!-- Jquery - ui right after-->
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="/tdk/scripts/bootstrap.js" type="text/javascript"></script>
<script src="/tdk/scripts/jquery.dataTables.js" type="text/javascript"></script>
<script src="/tdk/scripts/dataTables.bootstrap.js" type="text/javascript"></script>

