php - 如何在 CI Web 应用程序的就绪状态下添加粘性 toast 通知

标签 php jquery css codeigniter

我们如何在 codeigniter 站点中添加粘性 toast 通知。我需要在主页加载粘性 toast 通知。我们该怎么做

我试过了。但它不起作用。

<div>

<p>
        <span class="description">Show a success toast</span> <a href="javascript:showSuccessToast();">not
        sticky</a>|<a href="javascript:showStickySuccessToast();">sticky</a>
    </p>

    <p>
        <span class="description">Show a notice toast</span> <a href="javascript:showNoticeToast();">not sticky</a>|<a
            href="javascript:showStickyNoticeToast();">sticky</a>
    </p>

    <p>
        <span class="description">Show a warning toast</span> <a href="javascript:showWarningToast();">not
        sticky</a>|<a href="javascript:showStickyWarningToast();">sticky</a>
    </p>

    <p>
        <span class="description">Show a error toast</span> <a href="javascript:showErrorToast();">not sticky</a>|<a
            href="javascript:showStickyErrorToast();">sticky</a>
    </p>

</div>

<script type="text/javascript">

    function showSuccessToast() {
        $().toastmessage('showSuccessToast', "Success Dialog which is fading away ...");
    }
    function showStickySuccessToast() {
        $().toastmessage('showToast', {
            text: 'Success Dialog which is sticky',
            sticky: true,
            position: 'top-right',
            type: 'success',
            closeText: '',
            close: function () {
                console.log("toast is closed ...");
            }
        });

    }

最佳答案

即使我对 toast 消息有一些问题,所以我也这样做了

HTML 代码

<div class="toast toast-default">
     <button class="toast-dismiss"><i class="fa fa-times"></i></button>
                Oops!!! Something went wrong while adding this product. Please try again after sometime.
 </div>

CSS

.toast-default {
    background: rgba(53, 164, 178, 0.8) none repeat scroll 0 0;
    color: #fff;
}
.toast {
    border-radius: 5px;
    display: none;
    font-family: "ralewayregular";
    padding: 20px 10px 10px;
    position: fixed;
    right: 20px;
    text-align: center;
    top: 100px;
    width: 250px;
    z-index: 1000;
}

脚本代码

 $('.toast-default').fadeIn(400).delay(3000).fadeOut(400);

当你想要 toast 消息时调用该脚本。

关于php - 如何在 CI Web 应用程序的就绪状态下添加粘性 toast 通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32087728/

相关文章:

php - PHP 主页上的新项目

javascript - 使用 jQuery 进行内联编辑

html - 直到刷新才应用 CSS 样式

javascript - 导航移动下拉菜单,制作屏幕尺寸

php - 如何从 php 启动和停止 perl 守护进程

php - 同一页面上有两个ajax,但第二个没有得到第一个已更改的内容

css - 如何更改 Angular 4 中变量 Sass 的值?

css - 在全屏页面上仅垂直对齐 2 个元素

刷新时重新生成 PHP session_id

javascript - if 语句的多个简写?