Friday, July 26, 2013

Stay Modal, My Friends

I don’t often need to prevent a SharePoint 2010 modal dialog window from closing, but when I do I use the code below:

//step 1: check if we are in a dialog
var dlg = typeof (SP.UI.ModalDialog.get_childDialog) == "function" ? SP.UI.ModalDialog.get_childDialog() : null;

if (dlg != null && dlg.$5_0) {
//step 2: hide close button
dlg.$5_0.style.display = "none";
}



Then, when you want to allow the dialog to be closed again, the code is:



//step 1: check if we are in a dialog
var dlg = typeof (SP.UI.ModalDialog.get_childDialog) == "function" ? SP.UI.ModalDialog.get_childDialog() : null;

if (dlg != null && dlg.$5_0) {
//step 2: show close button
dlg.$5_0.style.display = "inherit";
}

No comments:

Post a Comment

 
© I caught you a delicious bass.
Back to top