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();

Regards

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

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

Thanks,

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.

Thanks

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,


<script>

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

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

</script>

[b]

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

this will disappear flash message after 3 sec.