Liferay:提交时关闭弹出窗口?

时间:2015-05-04 09:37:08

标签: javascript liferay liferay-6

下面我用于打开弹出窗口的代码。如何在提交时关闭相同的内容?

function popupCreation(url){
        AUI().use('liferay-util-window', 'aui-io-deprecated', 
        function(A) {
            modal=Liferay.Util.openWindow({
                dialog: {
                    id:'closeid',
                    centered: true,
                    modal: true,
                    width: 950,
                    height:750,
                },
                uri: '<%=editSettingsURL%>'
            });
        });
    }

3 个答案:

答案 0 :(得分:1)

此页面可能会有所帮助 - How to close a Dialog IFrame in Liferay 6.2

如果您定义这样的模态窗口(让我们在 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>

并在对话框页面内创建按钮触发器(或您的案例中的onsubmit事件监听器)( dialog.jsp ):

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

答案 1 :(得分:0)

试试这个

Liferay.Util.getOpener().<portlet:namespace />closePopup('<portlet:namespace />YOUR_POPUP_ID')

答案 2 :(得分:0)

请尝试使用以下代码关闭弹出窗口:

AUI().use('liferay-util-window', 'aui-io-deprecated', 
function(A) {
    modal=Liferay.Util.openWindow({
        dialog: {
            id:'closeid',
            centered: true,
            modal: true,
            width: 950,
            height:750,
        },
        uri: '<%=editSettingsURL%>'
    });
});
Liferay.provide(
   window,
  'closePopup',
  function(popupIdToClose) {
       var dialog = Liferay.Util.getWindow(popupIdToClose);
       dialog.destroy(); // You can try toggle/hide whatever You want
      },
     ['aui-base','aui-dialog','aui-dialog-iframe']
     );
  }); 
 });