Flash Message onClick

Hi All,

I have a link that I would like to call a Flash Message with an onclick event.

What I’m finding is the Flash message gets executed on page load and not the click event.

  9     <?php 

 10     echo CHtml::link('xxxx', 

 11         array('xx/xxxx',),

 12         array('onclick'=>Dialog::message('XXXX', 'Please be patient will we generate xxxxx.'))   

 13     ); 

 14     ?> 

Dialog::message basically calls Yii::app()->user->setflash();


you can call controller/action on link click and pass a parameter with that,

when parameter set( present ) show flash (error/success) message.


Tried your suggestion, but the flash only appears once the script has run.

The script takes a while to run, and what I’m trying to achieve is to get the flash message to appear at the start of the script.


you mean you need that on button click frequently and before submitting,

but it will appear flash message for a while and than submit action call, user can not judge what happen.

if you want to disappear flash message after some time you can use,


	setTimeout(function(){ $(".flash-error").fadeOut("slow"); },3000);

	setTimeout(function(){ $(".flash-success").fadeOut("slow"); },3000);



You can put in layout file so it will apply to all pages…[/b]

this will disappear flash message after 3 sec.