2

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

Thanks.

1 Answer 1

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) {

    }
}
9
  • What i want to do first is open an already existing modal creating when you install sharepoint, how can i do that ? Commented Apr 12, 2012 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? Commented Apr 12, 2012 at 16:47
  • Yes i want to use something like, ModalDialog.Open("/UserRegister.aspx") to open already existing Sharepoint Modal Commented Apr 12, 2012 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. Commented Apr 12, 2012 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. Commented Apr 12, 2012 at 18:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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