Yii Framework Forum: How To Autoclose Or Destroy Cjuidiaсог After 5 Seconds? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How To Autoclose Or Destroy Cjuidiaсог After 5 Seconds? Rate Topic: -----

#1 User is offline   almix 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 28
  • Joined: 23-September 11

Posted 19 December 2012 - 06:39 AM

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

0

#2 User is offline   mbala 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 157
  • Joined: 21-July 12
  • Location:Chennai, Tamilnadu, India

Posted 19 December 2012 - 08:06 AM

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
0

#3 User is offline   almix 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 28
  • Joined: 23-September 11

Posted 19 December 2012 - 08:23 AM

View Postmbala, on 19 December 2012 - 08:06 AM, said:

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

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users