Skip to content

Instantly share code, notes, and snippets.

@javierguerrero
Created January 7, 2016 16:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save javierguerrero/5249652dea3d389727e0 to your computer and use it in GitHub Desktop.
Save javierguerrero/5249652dea3d389727e0 to your computer and use it in GitHub Desktop.
<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
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