hi i have flash message to show success message and i want hide that after 3 seconds . i use js code but in line 3 when i use view::POS_READY i get error to not found that class so i comment this line and after that js code not worked and not fade my message. how can fix this problem?
this is my show flash code in view:
<?php if(Yii::$app->session->hasFlash('flashMessage')):?>
<div class="flash-success">
<?php echo Yii::$app->session->getFlash('flashMessage'); ?>
<?php
$this->registerJs(
"$('.flash-success').animate({opacity: 1.0}, 3000).fadeOut('slow');",
//view::POS_READY,
'myHideEffect'
);
?>
set flash in controller:
if ($model->load(Yii::$app->request->post()) && $model->save()) {
Yii::$app->session->setFlash('flashMessage', 'success');
return $this->redirect('index.php');
}
Try this... or you can "use \yii\web\View;" on top of the view file