簡體   English   中英

JQuery UI 對話框:TypeError: a(...).parents(...).andSelf 不是函數

[英]JQuery UI dialog : TypeError: a(...).parents(...).andSelf is not a function

我是 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)

我使用了這些 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>

我調用的函數是這個:

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();
}

我知道這個 append 很奇怪,但這只是為了嘗試對話框。

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(); });
 .ui-dialog-titlebar-close { float:right} .ui-dialog-titlebar-close::after { content:"X" }
 <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"/>

.andSelf()在 jQuery 1.8 中被棄用,在 jQuery 3.0 中被移除。

從 jQuery 1.8 開始,應該使用.addBack()代替。

嘗試在代碼中用“addBack”替換“andSelf”

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM