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

March 7th, 2012 | Posted by Marijn in css | jquery / javascript | sharepoint

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.

You can follow any responses to this entry through the RSS 2.0 You can leave a response, or trackback.

2 Responses



Leave a Reply

%d bloggers like this: