How to use SP.UI.ModalDialog.showWaitScreenWithNoClose to display loading message

vrm 711 Reputation points
2022-05-18T02:41:39.247+00:00

My current script:

    function openDialog(pageUrl) { 
    var options = { 
    url: pageUrl, 
    title: ' ', 
    allowMaximize: false, 
    showClose: true, 
    width: 726, 
    height: 375,
    }
         SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options); 
    }

Works fine, however, the modal takes time to populate with content.
How do I add "SP.UI.ModalDialog.showWaitScreenWithNoClose" to my script so that a visitor sees progress and the progress window closes when the modal is populated?
I need to be shown exactly what I need to put on the page, I am not a programmer. Thanks.

Microsoft 365 and Office | SharePoint | For business | Windows
0 comments No comments
{count} votes

Accepted answer
  1. RaytheonXie_MSFT 40,471 Reputation points Microsoft External Staff
    2022-05-18T09:04:10.057+00:00

    Hi @vrm ,
    You can refer to following code to show wait message while dialog loading

    		function openDialog(pageUrl) {  
    			var options = {  
    				url: pageUrl,  
    				allowMaximize: false,  
    				showClose: true  
    			};  
    			SP.UI.ModalDialog.showModalDialog(options);  
    			showWait();  
    		}  
    
    		var waitDialog = null;  
    
    		function showWait() {  
    			ExecuteOrDelayUntilScriptLoaded(function() {  
    				waitDialog = SP.UI.ModalDialog.showWaitScreenWithNoClose(SP.Res.dialogLoading15);  
    				// DO SOMETHING;  
    				DoSomeWorkUsingAjax(myCallBack)  
    
    			}, sp.js);  
    		}  
    
    		function myCallBack() {  
    			if (!fIsNullOrUndefined(waitDialog)) {  
    				waitDialog.close(SP.UI.DialogResult.OK);  
    				//or SP.UI.ModalDialog.close();  
    			}  
    		}  
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.