SharePoint 2013 showModalDialog 彈出模式窗口

1. SharePoint 彈出框ui

本文講述SharePoint 2013 中使用 SP.UI.ModalDialog.showModalDialog時 showModalDialog  未定義的問題。url

function showDialog(title,url,width,height) {
    var options = {
        url:url,
        args: 7,
        title: title,
        dialogReturnValueCallback: dialogCallback
    };
    if (width != undefined) options.width = width;
    if (height != undefined) options.height = height;
 
   SP.UI.ModalDialog.showModalDialog(options);
   
}

//接收返回值方法
function dialogCallback(dialogResult, returnValue) {
    //其中dialogResult=1,表明肯定,dialogResult=0,表明關閉
    if (returnValue != null && dialogResult == 1) {
    
    }
    return;
}

 

上面的代碼在SharePoint 2010中是能夠正常工做的,就是顯示一個 有模式的窗口。spa

但在SharePoint  2013 中會出現 (ModalDialog )showModalDialog  未定義的錯誤,如何解決這個問題呢?使用  SP.SOD.executeFunc :code

 1 function showDialog(title,url,width,height) {
 2     var options = {
 3         url:url,
 4         args: 7,
 5         title: title,
 6         dialogReturnValueCallback: dialogCallback
 7     };
 8     if (width != undefined) options.width = width;
 9     if (height != undefined) options.height = height;
10  
11     SP.SOD.executeFunc(
12      'sp.ui.dialog.js',
13      'SP.UI.ModalDialog.showModalDialog',
14      function () {
15          SP.UI.ModalDialog.showModalDialog(options);
16      });
17    
18 }
19 
20 //接收返回值方法
21 function dialogCallback(dialogResult, returnValue) {
22     //其中dialogResult=1,表明肯定,dialogResult=0,表明關閉
23     if (returnValue != null && dialogResult == 1) {
24     
25     }
26     return;
27 }

 

2.關閉彈出框blog

//關閉
function closeDialog() {
    window.frameElement.cancelPopUp();
}
相關文章
相關標籤/搜索