509.949.2162 jeremy@bondbyte.com

Customer request modal dialogs from time to time in their applications. We use Twitter Bootstrap pretty heavy but sometimes we don’t have complete control over the JavaScript Framework. In those cases you’re forced to use the OOB SharePoint Modal implementation. The default SharePoint Master Page(s) do not include a reference to SP.UI.Modal.js. You can add the reference in the master page but then it loads on every page. New to 2013 is the Script on Demand concept.

SP.SOD.executeFunc('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', function () { ShowCustomModalDialog(); });

function ShowCustomModalDialog()
{
//Using a generic object.
var options = {
title: “My Dialog Title”,
width: 400,
height: 600,
showClose: false,
url: “http://www.google.com” };

SP.UI.ModalDialog.showModalDialog(options);
}