0

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

Prakash K
  • 11,669
  • 6
  • 51
  • 109
  • Here are some questions to ask to solve this: 1) have you created the closePopup function at the right place? 2) is it getting called? 3) I am sure there might be js errors, so please check for javascript errors in firebug console when you click to close the pop-up. And I don't think it is related to 6.2 version. – Prakash K Dec 07 '13 at 13:01
  • It is related to version as 6.2 came up with new java script functions added. – Shahbaj Maner Sep 10 '15 at 09:27

4 Answers4

0

Add a Cancel / Close button with following script in your jsp.

<input type="button" onclick="hidePopup();" value="Cancel" />

function hidePopup(){
    AUI().ready('aui-dialog', function(A){
        A.DialogManager.hideAll();
    });
}
Parkash Kumar
  • 4,710
  • 3
  • 23
  • 39
0

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

Simpler Solution

A much simpler solution is to use the close-panel class name.

<aui:button cssClass="close-panel" type="cancel" value="close" />

No additional JavaScript required.

Chris Maggiulli
  • 3,375
  • 26
  • 39
0

I am working with Liferay 7.2 and I have used the next code in JavaScript:

Liferay.fire('closeWindow',{id:'idPopup'});

in your case idPopup = 'portlet:namespace/shahbaj'

Sorry I dont speak english very good

Felix Garcia
  • 180
  • 1
  • 4