简体   繁体   English

未捕获的类型错误:$(...).tooltip 不是函数

[英]Uncaught TypeError: $(…).tooltip is not a function

I have a project based in Spring Web model-view-controller (MVC) framework.我有一个基于 Spring Web 模型-视图-控制器 (MVC) 框架的项目。 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部署在 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>

Can we see where you're using $.tooltip() ?我们能看到你在哪里使用$.tooltip()吗? It's possible that it occurs somewhere before the jQuery UI embed line.它可能发生在 jQuery UI 嵌入行之前的某个地方。 So try re-arranging your script includes so jQuery is first, jQuery UI is second, then along through the rest.因此,请尝试重新安排您的脚本包含,因此 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()调用,就$.toolTip()知道。

One other quick attempt would be to substitute jQuery for $ where you're using, ie:另一种快速尝试是将jQuery替换为您正在使用的$ ,即:

$(".tips").toolTip()

would become:会变成:

jQuery(".tips").toolTip()

Be aware that jquery-ui has its own .tooltip() function and Bootstrap does 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>

It's probably due to the version of jQuery.这可能是由于 jQuery 的版本。 At least it was me and I solved this problem like this.至少是我,我像这样解决了这个问题。 I was using jQuery 3.3.1.我使用的是 jQuery 3.3.1。 The problem was solved when I changed the django to 1.10.3.当我将 django 更改为 1.10.3 时,问题解决了。 Add this,添加这个,

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.它需要工作。

Because jQuery 3.5.1 is getting larger it takes more time to load, in addition to the ordering of the JavaScript files, mentioned in many answers to this question, the way to go in addition to fixing the order which by the way does not always work, for Bootstrap tooltip option , a work around is to use a timeout based on jQuery loading time, example:因为jQuery 3.5.1变得越来越大,所以加载需要更多时间,除了在这个问题的许多答案中提到的 JavaScript 文件的排序之外,除了修复顺序之外的方法并不总是工作,对于Bootstrap tooltip option ,解决方法是使用基于jQuery加载时间的超时,例如:

setTimeout(function () {
        $("[title]").tooltip({
            container: "body",
            placement: "top",
            delay: { show: 240, hide: 60 }
        });

        $("[title]").on("click", function () {
            $(this).tooltip("hide");
        });
    }, 545*1.33); // 545ms timing to load jQuery.js + network estimated delay 

tooltip() was only added to jQuery UI in jQuery UI version 1.9. tooltip()仅在 jQuery UI 版本 1.9 中添加到 jQuery UI。 Proof...证明...

version added: 1.9 (Source: API.jQueryUI.com: Tooltip Widget .)添加的版本:1.9(来源: API.jQueryUI.com:工具提示小部件。)

If you don't have a version of jQuery UI at version 1.9 or higher, you'll get the error: tooltip() is not a function() .如果您没有 1.9 或更高版本的 jQuery UI,您将收到错误: tooltip() is not a function()

To solve this you'll have to add to your gemfile:要解决这个问题,您必须添加到您的 gemfile 中:

gem 'jquery-ui-rails'
gem 'jquery-ui-themes'

Then you won't have the problem that jquery-ui isn't loading anymore Another solution is to require("bootstrap") in application.js seemingly in addition to import("bootstrap") and you have install jquery and bootstrap with yarn too I think this all pretty crazy那么你就不会有 jquery-ui 不再加载的问题了另一个解决方案是在 application.js 中 require("bootstrap") 除了 import("bootstrap") 之外,你已经安装了 jquery 和 bootstrap with yarn我也觉得这一切都很疯狂

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未捕获的类型错误:$(...).tooltip 不是函数错误 - Uncaught TypeError: $(...).tooltip is not a function error Rails Webpacker - 未捕获的类型错误:$(...).tooltip 不是 function - Rails Webpacker - Uncaught TypeError: $(…).tooltip is not a function 未捕获的类型错误:$(...).tooltip 不是 Laravel 应用程序中的函数(Bootstrap 4 预设) - Uncaught TypeError: $(…).tooltip is not a function in Laravel application (Bootstrap 4 preset) Reactjs - 未捕获的类型错误:$node.attr(…).tooltip 不是 function - Reactjs - Uncaught TypeError: $node.attr(…).tooltip is not a function 未捕获的TypeError:函数不是函数 - Uncaught TypeError: Function is not a function 未捕获的TypeError: <function> 不是功能 - Uncaught TypeError: <function> is not a function 未捕获的typeerror对象没有方法“工具提示” - uncaught typeerror object has no method “tooltip” kendo-chart-tooltip 生成脚本错误 Uncaught TypeError: background.isDark is not a function - kendo-chart-tooltip generating script error Uncaught TypeError: background.isDark is not a function 未捕获的TypeError:undefined不是函数 - Uncaught TypeError: undefined is not a function 未捕获的TypeError:对象不是函数? - Uncaught TypeError: object is not a function?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM