jQuery Modal没有在点击事件上第二次打开

时间:2016-10-11 16:45:46

标签: javascript jquery modal-dialog

我正在开发一个通用函数来在click事件上显示jQuery Modal。  它首次显示模态弹出窗口,但第二次出现如下所示的错误:

data.frame(value=1:5, group1=c("A","A","A","B","B"), group2=c("a1","a2","a3","b1","b2"))

这是代码:

Uncaught TypeError: jQuery(...).dialog is not a function

以下是点击功能:

function initPopup(params) {
        jQuery('#pci-popup-dialog').remove();
        jQuery('<div id="pci-popup-dialog" style="display:none;" ></div>').appendTo('body');        
        var src='',title='',dataType='html',loadType='S';
        var w = 700;
        var h = 700;
        if (params.src != '' || params.src != undefined) {
            src = params.src;
        }
        if (src == '') {
            return false; // return nothing to show
        }
        if (params.title != '' && params.title != undefined) {
            title = params.title;
        }
        if (params.dataType != '' && params.dataType != undefined) {
            dataType = params.dataType;
        }

        if (params.width != '' && params.width != undefined) {
            w = params.width;
        } else {
            w = 700;
        }
        if (params.height != '' && params.height != undefined) {
            h = params.height;
        } else {
            h = 700;
        }
        if (params.loadType != '' && params.loadType != undefined) {
            loadType = params.loadType;
        }
        if (loadType == 'A') { //ajax content loading
            requestRunning = true;
            jQuery.ajax({
                type: "POST",
                dataType : dataType,
                url: src,
                success: function (data) { 
                    // init url popup box
                    jQuery("#pci-popup-dialog").dialog({
                        autoOpen: false,
                        modal: true,
                        title: "Pyramid Popup",
                        width: parseInt(w),
                        height: parseInt(h)
                    });
                    jQuery("#pci-popup-dialog").html(data);
                    jQuery("#pci-popup-dialog").dialog({
                        title: title,width: w,height: h
                    }).dialog("open");
                },
                complete: function() {
                    requestRunning = false;
                }
            }); 
        } else { // static content loading
            jQuery("#pci-popup-dialog").html(src);
                jQuery("#pci-popup-dialog").dialog({
                  title: title,width: w,height: h
                }).dialog("open");
        }
    }

任何帮助都将受到高度赞赏,因为我想知道遗失了什么......

0 个答案:

没有答案