CJuiDialog: start a function on close [x]

Hi,

I’m trying to bind an function ( stopInterval() ) on the exit-icon (X) in the upper right corner of an CJuiDialog window. The function should run one time, if the user close the window.

Is this possible to define something like an trigger for that?

Thank you, rall0r

Is there no way?

I think, an possible solution would be, by adding the jQuery event to the dialog, like:


$( "#myDialog" ).dialog({

   beforeClose: function(event, ui) { ... }

});

Isn’t it possible to define that “beforeClose” event by creating the CJuiDialog widget, in the same way like adding jQuery options?

Something like that:


$this->beginWidget('zii.widgets.jui.CJuiDialog', array(

    		'id'=>'myDialog',

    		// additional javascript options for the dialog plugin

    		'options'=>array(

		        'title'=>'Trends',

      		        'autoOpen'=>false,

		        'maxHeight'=>600,),

                 'events'=>array(

                        'beforeClose'=>'function ....

Should work if you use the ‘js:’ prefix:




'events'=>array(

  'beforeClose'=>'js:function ....

)



See CJuiDialog: How to set option ‘buttons’.

no, unfortunately it does not work.

It seams, "events" is "not supported" for CJuiDialog":


Property "CJuiDialog.events" is not defined. 

True. It seems you don’t need to specify that you’re configuring the events. From jQuery API:

They simply provide the event callback as a configuration option. So maybe it works like this:




$this->beginWidget( 'zii.widgets.jui.CJuiDialog', array(

  'id'=>'myDialog',

  'options'=>array(

    'title'=>'Trends',

    'autoOpen'=>false,

    'maxHeight'=>600,

    'close'=>'js:function(){ alert("closed") }',

  ),

));