zoukankan      html  css  js  c++  java
  • SharePoint 2013 showModalDialog 弹出模式窗口

    1. SharePoint 弹出框

    本文讲述SharePoint 2013 中使用 SP.UI.ModalDialog.showModalDialog时 showModalDialog  未定义的问题。

    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中是可以正常工作的,就是显示一个 有模式的窗口。

    但在SharePoint  2013 中会出现 (ModalDialog )showModalDialog  未定义的错误,如何解决这个问题呢?使用  SP.SOD.executeFunc :

     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.关闭弹出框

    //关闭
    function closeDialog() {
        window.frameElement.cancelPopUp();
    }
  • 相关阅读:
    Scripts.Render 索引超出了数组界限
    AutoFac使用方法总结
    MFC中打开一个获取路径的对话框
    MFC中自定义消息
    获得窗口句柄的方法
    App Doc View Frame中指针的获取
    MFC中菜单的命令响应顺序
    机械设计软件编写心得
    对SVD奇异值分解的理解
    安装win8+Ubuntu14.04双系统的经验总结
  • 原文地址:https://www.cnblogs.com/liyuxin/p/3831601.html
Copyright © 2011-2022 走看看