1

Foll. is our code to open modal dialog in SharePoint 2013. It worked in 2010. In 2013, I have put a debugger and notice that the debugger wont go into the line after ExecuteOrDelayUntilScriptLoaded. What might be the issue?

function OpenDialog(url, width, height) {
    debugger;
    ExecuteOrDelayUntilScriptLoaded(openModalDialog, "SP.JS");
    function openModalDialog() {
        options = SP.UI.$create_DialogOptions();
        options.url = url;
        options.showClose = false;
        options.allowMaximize = false;
        if (width != '') {
            options.width = width;
        }
        if (height != '') {
            options.height = height;
        }

        options.dialogReturnValueCallback = Function.createDelegate(null, CloseCallback);
        SP.UI.ModalDialog.showModalDialog(options);

    }
}

function CloseCallback(result, target) {

}  

*UPDATE: I changed the code to the foll. and it has resolved the issue. I would like to know whats happening in SP2013 that is causing this issue?*

 function OpenDialog(url, width, height) {
            debugger;
            var options = {
                url: url,
                showClose:false,
                allowMaximize:false
            };

            if (width != '') {
                options.width = width;
            }
            if (height != '') {
                options.height = height;
            }

                options.dialogReturnValueCallback = Function.createDelegate(null, CloseCallback);
                SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);

            }


        function CloseCallback(result, target) {

        }  
1

In SP2013 this is the correct way to do it according to Microsoft @ http://msdn.microsoft.com/en-us/library/jj245759.aspx

// Make sure the SharePoint script file 'sp.js' is loaded before your // code runs.

SP.SOD.executeFunc('sp.js', 'SP.ClientContext', openModalDialog);

Reference:

ExecuteOrDelayUntilScriptLoaded not executing after page publish

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.