How To Autoclose Or Destroy Cjuidiaсог After 5 Seconds?

I have dialog for flash messages. But now the user must click close or escape button. I want to destroy dialog after 5 seconds, but only form inside this dialog destroys (( May be use something else instead of CJuiDialog ? Help please.


<?php

if($flashes = Yii::app()->user->getFlashes()) {

    foreach($flashes as $key => $message) {

        if($key != 'counters') {

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

                        'id'=>$key,

                        'options'=>array(

                            'show' => 'blind',

                            'hide' => 'explode',

                            'modal' => 'true',

                            'title' => $message['title'],

                            'autoOpen'=>true,

							'dialogClass'=>$message['type'],

							'buttons'=>array('Закрыть'=>'js:function() {$(this).dialog("close");}'),

							'close'=>'js:function(e,ui){

							                        $(this).dialog("destroy").remove();

							                    }',

                        ),

						'htmlOptions'=>array(

							        			'class'=>'flash-success',

											),

                        ));

 

            printf('<span class="dialog">%s</span>', $message['content']);

 

            $this->endWidget('zii.widgets.jui.CJuiDialog');

        }

    }

}

updated code




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

    'id'=>'dialogbox',

    // additional javascript options for the dialog plugin

    'options'=>array(

        'title'=>'Dialog box 1',

        'autoOpen'=>true,

        'open' => 'js:function(event, ui) {            

            setTimeout(function() {

                 $("#dialogbox").dialog("close");

            }, 5000);

        }',

    ),

));



Bsourcecode

YES!!!! It’s great! Thank you very much, mbala!