TypeError:$(...)。dialog不是devserver上的函数

时间:2014-06-10 15:21:16

标签: javascript jquery html jquery-ui

我有一个母版页,其中包含以下css / js:

<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="resources/css/jquery-ui.css"> 

这是我用来打开弹出窗口的函数,我传递了一些参数来加载弹出窗口。

function planDataInputPopup(dialogId, formID, actionName, popHeight, popWidth, paramData) {

$(dialogId).dialog({
    autoOpen : true,width : popWidth,modal : true,dialogClass: 'no-close',
    draggable: true, resizable: true, position: [306,105],
    buttons : {
        "Create" : function() {
                if(document.getElementById("dropDownCounter").value != null){
                    document.getElementById("dropDownCounter").value=dropDownCounter+1;
                } 
                document.getElementById("inputPopupMode").value=true;
                if(paramData == 'false'){
                    submitInputFormUsingAjax(formID,actionName,"#inputFormMainDiv");
                }else{
                    submitMultipartFormUsingAjax(formID,actionName,"#inputFormMainDiv");
                }
                $(this).dialog("close");
                $(this).remove();
                //$(this).dialog("destroy");
        },

        Cancel : function() {
            $(this).dialog("close");
            $(this).remove();
            //$(this).dialog("destroy");
            return false;
        }
    },

    close : function() {
        $(this).dialog("close");
        $(this).remove();
        //$(this).dialog("destroy");
    }
});  }

上面的代码在本地工作正常,当我在开发服务器上部署时,我正在获得异常TypeError: $(...).dialog is not a function或某些时间为“$(this).dialog(”destroy“)”;

对话框应该关闭,但它不会在开发服务器上发生。

我没有得到什么错误。

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:4)

当您尚未加载TypeError: $(...).dialog is not a function时,

jqueryuithe error you get out of Firefox。其他浏览器有相同的错误。你可以

(1)仔细检查您的devserver是否有http://code.jquery.com/ui/1.10.3/jquery-ui.js的工作和非防火墙连接,或者更好 -

(2)下载a minified jquery-ui.js并将其包含在服务器上的third-partylib目录中,然后从那里获取(这是常见的做法)。


另请注意:呼叫$(this).remove()也会调用.destroy(),如果对话框仍处于打开状态,则.close()会调用$(this).dialog("close"); $(this).dialog("destroy"); 。这两行:

.destroy()

完全没必要,您可以安全地删除它们而不改变任何行为。基本上你是在连续两行调用{{1}},所以第二次调用会导致未初始化错误

相关问题