Open a SharePoint 2010 screen as modal dialog wherever you want via jQuery

My coworker at Belfius just found this cool trick to make your input screens cooler.
He pointed me to the blog of Tobias Lekman:
You can use the SP.UI.ModalDialog namespace via javascript. What his code does is open a SharePoint 2010 screen as modal dialog:

SharePoint modal dialog

The code

function test() {
        SP.UI.ModalDialog.showModalDialog({
                url: "http://yoursitecollection/yoursite//Lists/listname/NewForm.aspx",
                title: "Add item",
                allowMaximize: true,
                showClose: true,
                width: 800,
                height: 600,
                dialogReturnValueCallback: silentCallback
      });
};
function silentCallback(dialogResult, returnValue) {
}
function refreshCallback(dialogResult, returnValue) {
SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);
}

Simply point the url to the page you want to show.

About: Marijn

Marijn Somers (MVP) has over 14 years experience in the SharePoint world, starting out with SP2007. Over the years the focus has grown to Office 365, with a focus on collaboration and document management. He is a business consultant at Balestra and Principal Content Provider for "Mijn 365 Coach" that offers dutch employee video training. His main work tracks are around user adoption, training and coaching and governance. He is also not afraid to dig deeper in the technicalities with PowerShell, adaptive cards or custom formatting in lists and libraries. You can listen to him on the biweekly "Office 365 Distilled" podcast.


2 thoughts on “Open a SharePoint 2010 screen as modal dialog wherever you want via jQuery”

Leave a Reply

Your email address will not be published. Required fields are marked *