Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

i was wondering is there is a way to use existing modal popup already use by the sharepoint site and override their callbacks ?

Thanks

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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

    }
}
share|improve this answer
    
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
show 5 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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