2

I was wondering is there is a way to use the existing modal popup already used by SharePoint and override its callback?

Thanks.

3

Yea, there is a dialogReturnValueCallback option when using the SP.UI.ModalDialog.showModalDialog. See http://msdn.microsoft.com/en-us/library/ff410058%28v=office.14%29.aspx

In the callback function you can test to see whether the user clicked ok or cancel to close the dialog.

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

// Dialog callback
function CloseCallback(result, target) {
    if (result === SP.UI.DialogResult.OK) {

    }
    if (result === SP.UI.DialogResult.cancel) {

    }
}
  • What i want to do first is open an already existing modal creating when you install sharepoint, how can i do that ? – Dr.Denis McCracleJizz Apr 12 '12 at 16:11
  • So you want to tap into when SharePoint opens a modal and know when it's closed? What are you trying to accomplish with this? – Steve Lineberry Apr 12 '12 at 16:47
  • Yes i want to use something like, ModalDialog.Open("/UserRegister.aspx") to open already existing Sharepoint Modal – Dr.Denis McCracleJizz Apr 12 '12 at 16:58
  • What do you mean by an already existing modal? I don't see where my code above doesn't help you with the example you gave. Sorry. – Steve Lineberry Apr 12 '12 at 17:13
  • Sharepoint already has Modal popup defined, for when you add permissions for exemple, sharepoint will open a modal popup, i want to use the same modal popup but change its onclick and close callback. – Dr.Denis McCracleJizz Apr 12 '12 at 18:24

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.