How To Create Yii Popup Message Box?

I am a newer about Yii. I want to do this: in action create, I will check if the new record could be created, if not, then I will redirect to the creating page, before redirect, I want to popup a message box which shows the error message, but I tried just used javascript:

echo “<script type=‘text/javascript’>alert(‘errormessage’)</script>”

but failed. I tried CJuiDialog, but failed too.

Does anyone has any idea about it?

Thanks very much. :)

Hi,

Why are you trying to reinvent yii … this feature is built in yii

In controller before redirect

Yii::app()->user->setFlash(‘success’,$model->pgm_title );

$this->redirect(array(‘view’,‘id’=>$model->pgm_id));

In view file

foreach(Yii::app()->user->getFlashes() as $key => $message) {

echo '&lt;div class=&quot;flash-' . &#036;key . '&quot;&gt;' . &#036;message . &quot;&lt;/div&gt;&#092;n&quot;;

}

Yii::app()->clientScript->registerScript(

'myHideEffect',


'&#036;(&quot;.flash-success&quot;).animate({opacity: 1.0}, 1000).fadeOut(&quot;slow&quot;);',


CClientScript::POS_READY

);

This will show you error messages… just try this

Oh, thanks, I will try it. for now, I have found another way to meet my request. :)

[quote name=‘casilin’ post=‘226565’]

I am a newer about Yii. I want to do this: in action create, I will check if the new record could be created, if not, then I will redirect to the creating page, before redirect, I want to popup a message box which shows the error message, but I tried just used javascript:

echo “<script type=‘text/javascript’>alert(‘errormessage’)</script>”

but failed. I tried CJuiDialog, but failed too.

Does anyone has any idea about it?

Thanks very much. :)

[/quote]

Hi,

please see this forum and also see this wiki

I hope it’s some help.

Hey, I tried today, it is great!!! Thanks!

ok just remove the line

[color=#000000] setTimeout[/color]color=#666600;[/color][color=#000000]

                                [/color][color=#000088]if[/color][color=#666600]([/color][color=#000000]jQuery[/color][color=#666600].[/color][color=#000000]fancybox[/color][color=#666600]){[/color][color=#000000]


                                    setTimeout[/color][color=#666600]([/color][color=#000000] [/color][color=#008800]'&#036;.fancybox.close();'[/color][color=#666600],[/color][color=#006666]3000[/color][color=#666600]);[/color][color=#000000]


                                [/color][color=#666600]}[/color]

yes, I just found I can change the fade out time, and even I can remove the fade out code. Thanks. :)