【问题标题】:Showing Multiple Noty Notifications With a Delay延迟显示多个通知通知
【发布时间】:2012-06-04 23:02:22
【问题描述】:

我正在使用noty 来显示使用“右上角”警报设置的通知。我对 jquery 很陌生,但对 php 和 mysql 的了解足以完成我想做的大部分事情。

我想要做的是使用 mySQL 获取数据以查看是否需要向用户显示任何通知(完成)。然后在页面加载时显示该通知,我也这样做了,尽管我确信除了重复代码之外还有一种更优雅的方式来显示多个通知?

然后我想为每个通知的出现延迟 1 秒,这样它们就不会同时弹出并同时消失。我已经研究过 .delay() ,但对 jQuery 没有更好的了解,这对我来说毫无用处。

我的代码:

$(document).ready(function() {
  var noty_id = noty({"text":"a message","layout":"topRight","type":"inormation","animateOpen":{"height":"toggle"},"animateClose":{"height":"toggle"},"speed":1000,"timeout":5000,"closeButton":false,"closeOnSelfClick":true,"closeOnSelfOver":false,"modal":false});
  var noty_id = noty({"text":"a message","layout":"topRight","type":"inormation","animateOpen":{"height":"toggle"},"animateClose":{"height":"toggle"},"speed":1000,"timeout":5000,"closeButton":false,"closeOnSelfClick":true,"closeOnSelfOver":false,"modal":false});
});

【问题讨论】:

    标签: php jquery mysql notifications


    【解决方案1】:

    您可以只使用 setTimeout() 原生 Javascript 函数。这将在给定的超时时间(毫秒)后排队执行操作。

    $(document).ready(function() {
        var noty_id = noty({"text":"a message","layout":"topRight","type":"inormation","animateOpen":{"height":"toggle"},"animateClose":{"height":"toggle"},"speed":1000,"timeout":5000,"closeButton":false,"closeOnSelfClick":true,"closeOnSelfOver":false,"modal":false});
        setTimeout(function() {   var noty_id = noty({"text":"a message","layout":"topRight","type":"inormation","animateOpen":{"height":"toggle"},"animateClose":{"height":"toggle"},"speed":1000,"timeout":5000,"closeButton":false,"closeOnSelfClick":true,"closeOnSelfOver":false,"modal":false}); }, 5000)
    });
    

    您可能会发现jQuery Pines 是一个更好的通知系统,用于将多个通知排队。

    【讨论】:

    • 有没有像noty_id.show()这样说的函数
    猜你喜欢
    • 1970-01-01
    • 2015-10-11
    • 2017-06-12
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    • 2010-11-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多