SharePoint 2013中使用SP.UI.ModalDialog.showModalDialog时showModalDialog未定义的解决办法

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

  1.  function DialogCallback(dialogResult, returnValue)  
  2.           {                                          
  3.              if (returnValue == '1') {  
  4.              alert("operation successfully");  
  5.               }     
  6.     }            
  7.  
  8.  var options = {    
  9.                        url:'url',    
  10.                         600,    
  11.                        height: 630,    
  12.                        dialogReturnValueCallback: DialogCallback  
  13.                       };     
  14.  
  15. SP.UI.ModalDialog.showModalDialog(options);                

上面的代码在SharePoint 2010中是可以正常工作的,就是显示一个 有模式的窗口。

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

  1. function DialogCallback(dialogResult, returnValue)  
  1.          {                                          
  2.             if (returnValue == '1') {  
  3.             alert("operation successfully");  
  4.              }     
  5.    }            
  6.  
  1. var options = {    
  1.                       url:'url',    
  2.                        600,    
  3.                       height: 630,    
  4.                       dialogReturnValueCallback: DialogCallback  
  5.                      };   
  6.    
  7. SP.SOD.executeFunc(  
  8.      'sp.ui.dialog.js',  
  9.      'SP.UI.ModalDialog.showModalDialog',   
  10.      function(){  
  11.           SP.UI.ModalDialog.showModalDialog(options);});   
如果,您认为阅读这篇博客对你有帮助,点击一下左下角的[推荐] 如果,你想了解我的动态,点击一下左下角的[关注我] 因为,你们的支持正是我学习的动力 如需转载,请注明出处 如果对文章有任何问题,都可以再评论中留言,我会尽可能的答复您,谢谢你的阅读
原文地址:https://www.cnblogs.com/stevegp/p/4156461.html