安装:
1) 在主模板中包含 turbo-tribble.js 脚本:
echo $this->Html->script([
'jquery.min', // JQuery is required
'turbo-tribble'
]);
2) 在主模板中包含 turbo-tribble.css 样式表:
echo $this->Html->css([
'turbo-tribble'
]);
3) 将下面的 sn-p 添加到您的主模板中:
<div id="turbo-tribble">
<?php echo $this->Flash->render('tribble'); ?>
</div>
4) 将turbo_tribble.ctp 添加到src/Template/Element/Flash 文件夹中;
5) 将AppController.php 中的代码添加到您的AppController.php;
然后,您可以轻松地从您的 jQuery 以及您的控制器中使用这个通知插件:
// from jQuery
$('.selector').on('click', function() {
// your logic here
$tt.setFlash('Some good news!', 'success');
})
// from php
public function index()
{
// your logic here
$this->setFlash('Some notification', self::NOTICE);
}
更多信息在这里http://turbo-tribble.ml/