JQuery UI 对话框:TypeError: a(...).parents(...).andSelf 不是函数

War*_*gal 5 javascript jquery dialog typeerror

我是 jquery 新手,我想在调用函数时向我的页面添加一个对话框。每当我从控制台调用此函数时,都会显示该对话框,但出现以下错误。这是什么意思以及如何解决?

Uncaught TypeError: a(...).parents(...).andSelf is not a function
    at d (jquery-ui.min.js:5)
    at c (jquery-ui.min.js:5)
    at Array.tabbable (jquery-ui.min.js:5)
    at jquery.min.js:2
    at r (jquery.min.js:2)
    at se.select (jquery.min.js:2)
    at Function.se [as find] (jquery.min.js:2)
    at k.fn.init.find (jquery.min.js:2)
    at a.<computed>.<computed>.open (jquery-ui.min.js:5)
    at a.<computed>.<computed>._init (jquery-ui.min.js:5)
Run Code Online (Sandbox Code Playgroud)

我使用了这些 jquery 库:

<script src="../vendor/jquery/jquery.min.js"></script> //Given with my bootstrap theme
<script src="../vendor/jquery-easing/jquery.easing.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
Run Code Online (Sandbox Code Playgroud)

我调用的函数是这个:

function afficherPopupErreur() {
    $('body').append('<div id="dialog" title="Basic dialog"><p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the x icon.</p></div>');
    $( "#dialog" ).dialog();
}

Run Code Online (Sandbox Code Playgroud)

我知道这个附加很奇怪,但这只是为了尝试对话框。

Raf*_*shi 11

.andSelf()在 jQuery 1.8 中已弃用,并在 jQuery 3.0 中删除。

.addBack()应该从 jQuery 1.8 开始使用。

尝试将代码中的“andSelf”替换为“addBack”


mpl*_*jan 2

andSelf已弃用并删除 - 使用较新的 JQUI

也始终使用 HTTPS 版本

function afficherPopupErreur() {
  $('body').append('<div id="dialog" title="Basic dialog"><p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the x icon.</p></div>');
  $("#dialog").dialog();
}

$(function() {
  afficherPopupErreur();
});
Run Code Online (Sandbox Code Playgroud)
.ui-dialog-titlebar-close { float:right}
.ui-dialog-titlebar-close::after { content:"X" } 
Run Code Online (Sandbox Code Playgroud)
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.4.1/jquery.easing.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-ui-bootstrap/0.5pre/assets/css/bootstrap.min.css" />
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
Run Code Online (Sandbox Code Playgroud)