Javascript at the close of a dialog box

David B, modified 13 Years ago. New Member Posts: 9 Join Date: 3/29/13 Recent Posts
Hello,

I acutallly use a dialog box and I want to execute some javascript at the close of the dialog.

To display the dialog box, I use that function

function showPopup(url,titre) {
  
	AUI().use( 'aui-dialog', 'event', 'event-custom', function(A) {
	    
    	dialog = new A.Dialog({
			id: 'customDialog',
            title: titre,
            centered: true,
            draggable: false,
			resizable: false,
            modal: true,
            height:250,
            width:650

       	 }).plug(A.Plugin.IO, {uri: url}).render();
   		
       	 dialog.show();	 
  	});
}[code]

 If someone knows how I can  proceed.
Roshan Qureshi, modified 13 Years ago. Regular Member Posts: 159 Join Date: 8/24/10 Recent Posts
Hi David,

Not master in AUI but hope following code will work for you.
Each dialog has closethick id for close button.
A.one('#closethick').on(click,function(){})


Regards,
Roshan
thumbnail
Mayur Patel, modified 13 Years ago. Expert Posts: 358 Join Date: 11/17/10 Recent Posts
Rightly said ! Using jquery you can fetch close button id and As roshan mentioned, you can define ur logic inside that function emoticon
thumbnail
Chirag Patadia, modified 13 Years ago. Junior Member Posts: 29 Join Date: 2/3/12 Recent Posts
Hi David,

You can try with following 2 options:

Option-1:
$('#dialog').live("dialogclose", function(){
//code to run on dialog close
});

Option-2:
There is on property available in AUI Diaplog named "beforeClose".

$("#dialog").dialog({
...
beforeClose: function(event, ui) {
console.log('Event Fire');
},
...
});
thumbnail
Victor Zorin, modified 13 Years ago. Liferay Legend Posts: 1228 Join Date: 4/14/08 Recent Posts
If you use AUI, no jquery is required, would be too much...

See code below:
  AUI().use('aui-dialog', 'aui-io', 'event', 'event-custom', function(A) {
    var dialog = new A.Dialog({
    	on: {
    		close: function() {
 	   		 window.alert('before close');
 	   		}
    	},		    		
 	            title: myTitle,
            centered: false,
            draggable: true,
            modal: true
        }).plug(A.Plugin.IO, {uri: renderUrl}).render();
       
        dialog.show();
       
  });