rall0r  
          
              
                June 28, 2011, 12:55pm
               
              1 
           
         
        
          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
         
        
           
         
            
       
      
        
          
          
            rall0r  
          
              
                June 30, 2011, 10:57am
               
              2 
           
         
        
          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 ....
 
        
           
         
            
       
      
        
          
          
            Ben  
          
              
                June 30, 2011,  7:49pm
               
              3 
           
         
        
          Should work if you use the ‘js:’ prefix:
'events'=>array(
  'beforeClose'=>'js:function ....
)
See CJuiDialog: How to set option ‘buttons’.
         
        
           
         
            
       
      
        
          
          
            rall0r  
          
              
                July 1, 2011,  2:50pm
               
              4 
           
         
        
          no, unfortunately it does not work.
It seams, "events" is "not supported" for CJuiDialog":
Property "CJuiDialog.events" is not defined. 
 
        
           
         
            
       
      
        
          
          
            Ben  
          
              
                July 1, 2011,  7:15pm
               
              5 
           
         
        
          True. It seems you don’t need to specify that you’re configuring the events. From jQuery API:
Code examples 
Supply a callback function to handle the close event as an init option.
$( ".selector" ).dialog({
[indent]close: function(event, ui) { … }[/indent]
});
 
 
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") }',
  ),
));