casilin
(Casilin2005)
November 2, 2013, 3:59pm
1
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 '<div class="flash-' . $key . '">' . $message . "</div>\n";
}
Yii::app()->clientScript->registerScript(
'myHideEffect',
'$(".flash-success").animate({opacity: 1.0}, 1000).fadeOut("slow");',
CClientScript::POS_READY
);
This will show you error messages… just try this
casilin
(Casilin2005)
November 16, 2013, 11:58am
3
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 '<div class="flash-' . $key . '">' . $message . "</div>\n";
}
Yii::app()->clientScript->registerScript(
'myHideEffect',
'$(".flash-success").animate({opacity: 1.0}, 1000).fadeOut("slow");',
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.
Ankit_Modi
(Ankit Modi)
November 17, 2013, 12:42pm
4
[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.
casilin
(Casilin2005)
November 20, 2013, 1:16pm
5
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 '<div class="flash-' . $key . '">' . $message . "</div>\n";
}
Yii::app()->clientScript->registerScript(
'myHideEffect',
'$(".flash-success").animate({opacity: 1.0}, 1000).fadeOut("slow");',
CClientScript::POS_READY
);
This will show you error messages… just try this
Hey, I tried today, it is great!!! Thanks!
Ankit_Modi
(Ankit Modi)
November 20, 2013, 1:19pm
6
casilin:
Hey, I tried today, it looks great! but the message will disappear after maybe 1 second, it is not what I want, but still thank you.
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]'$.fancybox.close();'[/color][color=#666600],[/color][color=#006666]3000[/color][color=#666600]);[/color][color=#000000]
[/color][color=#666600]}[/color]
casilin
(Casilin2005)
November 20, 2013, 2:23pm
7
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]'$.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.