Search code examples
popupliferayliferay-6alloy-ui

How to close PopUp window in Liferay 6.2?


I am using Liferay UI for popup window in Liferay 6.2. I am getting the pop up but i can not close it.Why it is not working Liferay 6.2.

Below is my code which is written on parent page:

AUI().ready(function(A) {
    AUI().use('aui-dialog', 'aui-io', function(A) {
        var url = '<%=testPopupURL.toString()%>';
        Liferay.Util.openWindow(
                {
                    dialog: {
                        cache: false,
                        width:800,
                        modal: true
                    },
                    id:'<portlet:namespace/>shahbaj',              
                    uri: url
                }
            );

    Liferay.provide(
        window,
        '<portlet:namespace />closePopup',
        function(popupIdToClose) {
            var A = AUI();
            alert(popupIdToClose);
            A.DialogManager.closeByChild('#' + popupIdToClose);
        },
        ['aui-base','aui-dialog','aui-dialog-iframe']
        );
    });
});

Below code is pop-up page content:

<aui:button name="YES" value="YES" onClick="javascript:yes();"/>
<aui:script>
    function yes(){
        alert('pop');
        Liferay.Util.getOpener().<portlet:namespace />closePopup('<portlet:namespace />shahbaj');
    }
</aui:script>

Please help me out!!


Solution

  • This worked!!

    AUI().ready(function(A) {
            AUI().use('aui-dialog', 'aui-io', function(A) {
                    var url = 'http://localhost/url';
        Liferay.Util.openWindow(
                {
                    dialog: {
                        cache: false,
                        width:800,
                        modal: true
                    },
                       id:'shahbaj',              
                    uri: url
                }
            );
     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']
        );
            }); 
    });