0

Is there an event handler I could use to determine when sharepoint launches a modal?

2

with Javascript you can try using the following

function showdialogfunction(pageUrl) {
var options = { url: pageUrl, width: 800, height: 600 };
SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
}

if you want to set focus mouse on the dialog then use the following script

$("#id").click(function () {
            OpenPopUpPage("XXX.aspx", null, null, null)
            setTimeout(setFocusModalDialog, 100);
            return false;
        })
    });
    function setFocusModalDialog() {
        var iframe = $(".ms-dlgFrame")[0];
        iframe.contentWindow.focus();
    }

Set focus on SharePoint 2013 Modal dialog

  • Not sure what this is trying to do or how it helps? For example, I need to set keyboard/mouse focus inside the model once it loads. – Batman May 16 '17 at 1:39
  • FYI. I have updated my answer above – Supermode May 16 '17 at 5:20
1

To my knowledge there is no OOTB event handler being provided to us by the SP API. You might want to look at the following post: SP 2010 JavaScript events

0

In my library SharepointPlus I created a customized showDialogModal function with more options, and one of them is onurlload that triggers when the called URL is loaded.

To do it I check when the iframe (created by Sharepoint to load the URL of the modal) triggers the DOMContentLoad (using iFrameReady from https://stackoverflow.com/a/24603642/1134119).

This solution only works if the URL is in the same domain (because of the cross-domain security restriction).

  • The problem i have though is that I need to hooking into SharePoint's built in showDialogModal. For example, when you hit new Document, it opens a modal but it doesn't set the cursor focus inside that modal, so now I need to set the focus when this happens. Can you library help with that? – Batman May 16 '17 at 12:35
  • No it cannot. In your case you have to overwrite the default SP.UI.ModalDialog.showModalDialog or, the OpenPopUpPageWithDialogOptions() function... Good luck – AymKdn May 16 '17 at 16:12

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.