找到你要的答案

Q:Liferay: Close popup on submit?

Q:Liferay:关闭弹出窗口对提交?

Below code i have used for opening popup . How do i close the same on submit?

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%>'
            });
        });
    }

下面的代码我已经用打开弹出。我如何关闭相同的提交?

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%>'
            });
        });
    }
answer1: 回答1:

this page might be helpful - How to close a Dialog IFrame in Liferay 6.2

If you define your modal window like this (let's say in 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>

and create button trigger (or onsubmit event listener in your case) inside the dialog page (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>

you will get the window that opened the dialog by getOpener() function. In page that creates the dialog (view.jsp), you have to provide the closePopup function like this:

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

本页可能是有益的-如何关闭在Liferay 6.2对话框iframe

如果你确定你的模态窗口(比方说在这样的观点。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()功能。在页面创建对话框(观。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>
answer2: 回答2:

Try this

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

试试这个

Liferay.Util.getOpener().<portlet:namespace />closePopup('<portlet:namespace />YOUR_POPUP_ID')
answer3: 回答3:

Please try the below code for closing the popup:

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']
     );
  }); 
 });

请用下面的代码关闭弹出:

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']
     );
  }); 
 });
javascript  liferay  liferay-6