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();
}
相关文章
相关标签/搜索