此页面可能会有所帮助 -如何在 Liferay 6.2 中关闭对话框 IFrame
如果您像这样定义模态窗口(假设在view.jsp中):
<aui:button name="openDialog" type="button" value="open-dialog" />
<liferay-portlet:renderURL var="dialogURL" windowState="<%=LiferayWindowState.POP_UP.toString() %>">
<liferay-portlet:param name="mvcPath" value="/dialog.jsp" />
</liferay-portlet:renderURL>
<aui:script use="liferay-util-window">
A.one('#<portlet:namespace/>openDialog').on('click', function(event) {
Liferay.Util.openWindow({
dialog: {
centered: true,
height: 300,
modal: true,
width: 400
},
id: '<portlet:namespace/>dialog',
title: '<liferay-ui:message key="i-am-the-dialog" />',
uri: '<%=dialogURL %>'
});
});
</aui:script>
并在对话框页面( dialog.jsp )内创建按钮触发器(或在您的情况下为 onsubmit 事件侦听器):
<aui:button name="closeDialog" type="button" value="close" />
<aui:script use="aui-base">
A.one('#<portlet:namespace/>closeDialog').on('click', function(event) {
// Let's suppose that "data" contains the processing results
var data = ...
// Invoke a function with processgin results and dialog id
Liferay.Util.getOpener().<portlet:namespace/>closePopup(data, '<portlet:namespace/>dialog');
});
</aui:script>
您将通过 getOpener() 函数获得打开对话框的窗口。在创建对话框 ( view.jsp ) 的页面中,您必须像这样提供 closePopup 函数:
<aui:script>
Liferay.provide(
window,
'<portlet:namespace/>closePopup',
function(data, dialogId) {
var A = AUI();
// Here you can use "data" parameter
// Closing the dialog
var dialog = Liferay.Util.Window.getById(dialogId);
dialog.destroy();
},
['liferay-util-window']
);
</aui:script>