Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<a href="#" onclick="openInDialog(500,600,true,true,false,'http://www.google.com');">Google</a>
<a href="#" onclick="openInDialog(500,600,true,true,false,'http://server/sites/demo/Lists/News/NewForm.aspx?RootFolder=&IsDlg=1');">New Element</a>
Fuente:
https://alinimer.wordpress.com/2013/02/25/open-pages-and-forms-in-modal-dialog-for-sharepoint-2013/
//function to open pages in a dialog
function openInDialog(dlgWidth, dlgHeight, dlgAllowMaximize,dlgShowClose,needCallbackFunction, pageUrl)
{
var options = { url: pageUrl, width: dlgWidth, height: dlgHeight, allowMaximize: dlgAllowMaximize,
showClose: dlgShowClose
};
if(needCallbackFunction)
{
options.dialogReturnValueCallback = Function.createDelegate(null, CloseDialogCallback);
}
SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
}
function CloseDialogCallback(dialogResult, returnValue)
{
//if user click on OK or Save
if(dialogResult == SP.UI.DialogResult.OK)
{ // refresh parent page
SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.RefreshPage', SP.UI.DialogResult.OK);
}
// if user click on Close or Cancel
else if(dialogResult == SP.UI.DialogResult.cancel)
{ // Do Nothing or add any logic you want
}
else
{//alert("else " + dialogResult);
}
}
@xsiruse

This comment has been minimized.

Copy link

xsiruse commented May 18, 2017

Hello, thank you for solution.
I have an issue now:
after the OK action there is no refresh of parent page... What reason can this be? I'm inserting script to WebPart "Script Editor" on Wiki Page of SP2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.