for a complete description of this jquery plugin please visit jquery-toastmessage
for demos Click here...
Requirements ¶
...requirements of using this extension (e.g. Yii 1.1 or above)...
Usage ¶
simply extract the download to your extensions folder
Now you can implement the toastMessage in two ways.
- Using the widget itself
//in your view
//we have four types of message type : Success, Info, Warning and Error
$message = "this is yii at work";
$this->widget('ext.widgets.toastMessage.toastMessageWidget',
array('message'=>$message,'type'=>'Success',
'options'=>array('sticky'=>true)));
- Using the view file in the views directory of the toastMessage extension. I prefer this second method when i dont want to render a view from any action.
$message = "this is a fully customized toastMessage";
$this->renderPartial('ext.toastMessage.views.toastView',array('message'=>$message,
'type'=>'warning', 'options'=>array( 'sticky'=>true,
'position'=>'middle-right',
'stayTime'=>5000)),false,true);
Change Log ¶
Official release Nov 2 2012.
Nov 29 2012 ¶
- added the options property
- inEffectDuration: 600, // in effect duration in miliseconds
- stayTime: 3000, // time in miliseconds before the item has to disappear
- text: '', // content of the item
- sticky: false, // should the toast item sticky or not?
- position: 'top-right', // top-left, top-center, top-right, middle-left, middle-center, middle-right
// Position of the toast container holding different toast. // Position can be set only once at the very first call, // changing the position after the first call does nothing
- closeText: '', // text which will be shown as close button,
// set to '' when you want to introduce an image via css
close: null // callback function when the toastmessage is closed
create a new view for none rendered implement
nice extension
wonderful..
nice extension. just about to remind me Foxpro and foxpro for windows..
Use as flash message
Hi,
How to use it to show flash message? Also, display it dynamically after ajax call?
Cheers,
Daniel
@ Daniel
yes you can use it for dynamical ajax call but the condition is that
because the js script for the extensions are only loaded on request
you have to set the param ($processOutput=true) in your renderPartial method. (the default is false)
eg. $this->renderPartial('myView',array('model'=>$model),false,TRUE);
@Binkabir
Thank you for the prompt answer, my situation is like this: Currently, I provide container to display the message (error/success/info/warning) on layouts/main.php like below:
<div style="position: fixed; top: 50px; right: 20px; z-index: 10;"> <?php $this->widget('bootstrap.widgets.TbAlert', array( 'id' => 'msgBox', 'block' => false, // display a larger alert block? 'fade' => true, // use transitions? 'closeText' => '×', // close link text - if set to false, no close link is displayed 'alerts' => array(// configurations per alert type 'success' => array('block' => false, 'fade' => true, 'closeText' => '×'), // success, info, warning, error or danger 'info' => array('block' => false, 'fade' => true, 'closeText' => '×'), 'warning' => array('block' => false, 'fade' => true, 'closeText' => '×'), 'error' => array('block' => false, 'fade' => true, 'closeText' => '×'), 'danger' => array('block' => false, 'fade' => true, 'closeText' => '×'), ), )); ?> </div> <?php Yii::app()->clientScript->registerScript( 'myHideEffect', '$("#msgBox").animate({opacity: 0.5}, 5000).fadeOut("slow");', CClientScript::POS_READY ); ?>
From my TbGridView, I called
... array( 'class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{update} {delete}', 'afterDelete' => "function(link,success,data){ if(success) { var obj = jQuery.parseJSON(data); $('#msgBox').html( '<div class=\"alert alert-block alert-' + obj.status + ' fade in\">' + '<a class=\"close\" data-dismiss=\"alert\">×</a>' + obj.msg + '</div>'); $('#msgBox').animate({opacity: 0.5}, 5000).fadeOut('slow');} }", ...
I have no idea to replace this with the toast message. Any help?
Cheers,
Daniel
cs()
Please replace cs() with Yii::app()->clientScript in your code. cs() is not available everywhere.
Thanks for this extension!
@thyseus
thanks for the correction. I actually had some short cut definition for some yii components, which I forgot to replace.
now I have replaced it.
cheers
Nice!
Greetings, friend I think you have a problem, check the widget file ...
fix
here!
public function init(){ //publish the assets folder for the toastmessage $this->assets = Yii::app()->assetManager->publish(dirname(__DIR__).DIRECTORY_SEPARATOR.'toastMessage'.DIRECTORY_SEPARATOR.'assets'); Yii::app->clientScript()->registerScriptFile($this->assets.'/jquery.toastmessage.js'); Yii::app->clientScript()->registerCssFile($this->assets.'/css/jquery.toastmessage.css'); }
Error
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in C:\xampp\htdocs\yii\isims\protected\extensions\toastMessage\toastMessageWidget.php on line 49
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.