我正在使用SharePoint 2010,我已经设法在一个模态对话框中打开了一个列表。当您单击一个按钮时,我正在尝试在相同的模式对话框中打开另一个列表。(理想情况下,关闭第一个对话框然后打开另一个对话框)下面是我的模态对话框声明:
function OpenDialog(url)
{
var dialogOptions = SP.UI.$create_DialogOptions();
dialogOptions.url = url // URL of the Page
dialogOptions.title = 'Dialog Window'
dialogOptions.allowMaximize= true
dialogOptions.width = 635; // Width of the Dialog
dialogOptions.height = 335; // Height of the Dialog
SP.UI.ModalDialog.showModalDialog(dialogOptions); // Open the Dialog
}
function DialogCallback(){
SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel,'Cancelled');
}因此,我设法正确地关闭了对话框,但我似乎无法让它打开一个新的对话框。我已经以www.google.co.uk为例,我只需要它在相同的对话框中打开(替换当前的对话框),或者关闭当前的对话框并重新打开一个新的对话框.
href="#" onclick="window.frameElement.cancelPopUp(); OpenDialog(url);发布于 2016-10-28 13:24:42
您忘记了选项:dialogReturnValueCallback在您的选项对象中。
您可以向此参数传递一个函数。何时关闭模态(好的,取消.)这个函数将被执行。
做一些像这样的事:
function OpenDialog(url)
{
var dialogOptions = SP.UI.$create_DialogOptions();
dialogOptions.url = url // URL of the Page
dialogOptions.title = 'Dialog Window'
dialogOptions.allowMaximize= true
dialogOptions.width = 635; // Width of the Dialog
dialogOptions.height = 335; // Height of the Dialog
dialogOptions.dialogReturnValueCallback = Function.createDelegate(null,DialogCallback )
SP.UI.ModalDialog.showModalDialog(dialogOptions); // Open the Dialog
}
function DialogCallback(result, target) {
if (result == SP.UI.DialogResult.OK) {
//Close the Modal with the function : SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK, returnValue);
//Here Your First Modal is close normaly, open Your New Modal Dialog
}else if (result == SP.UI.DialogResult.cancel){
//Close the modal with the function : SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel,returnValue);
} else{
//The user have closed the modal with the cross
}
}因此,在您的父页面中,jsute调用:
OpenDialog(url);在你的第一个模态中,关闭正常的模态:
SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK, "a value to return ...");然后将执行DialogCallback函数,然后您可以打开新的Modal
https://stackoverflow.com/questions/40287776
复制相似问题