What's wrong with this code? dialog is not a function

寵の児 提交于 2019-12-25 05:06:28

问题


I'm trying to solve another issue I'm having with autotab. For this site it's just not working, I keep getting autotab is undefined, when everything's being called correctly.

I also notice in the console I'm receiving "TypeError: $(...).dialog is not a function"

The block it's referencing is this:

$('#dialog-modal').dialog( {
    position: ['center'],
    autoOpen: false,
    modal: true,
    buttons: [{
        text : "Close",
        "class" : 'closeButtonClass',
        click : function(e) {
            document.getElementById("modalPopup").src = "about:blank";
            $('#dialog-modal').dialog("close");
        }
    }]
});

Can anyone please tell me what could be wrong? It's saying the error is on the line that has "click : function(e) {" but that can't be right, as there's no call to .dialog there.


回答1:


dialog() is not a method within the standard jQuery library; it is part of jQueryUI, which it looks like you have not added to your page. Add the following code to the head of your page, after you include jquery.js:

<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" />


来源:https://stackoverflow.com/questions/24402531/whats-wrong-with-this-code-dialog-is-not-a-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!