【问题标题】:Close all pnotify notifications when a specific notification shows up出现特定通知时关闭所有 pnotify 通知
【发布时间】:2014-07-18 06:35:28
【问题描述】:

我正在使用 pnotify 插件。我的代码如下:

$('.input_elements').on('change', function() {
   if ($(this).val() > 2) {
      $.pnotify({
         text: 'Quantity exceeds the number of available items.',
         type: 'error',
         delay: 2500,
         history: false,
         sticker: true
      });
   } else {
      $.pnotify({
         text: 'Saved.',
         type: 'success',
         delay: 2500,
         history: false,
         sticker: true
      });
   }
});

我的问题是,当此通知出现在.input_elementschange 事件中时,如何让页面上的所有其他可见通知消失。 pnotify 是否有一个选项可以在打开另一个选项时使其消失?

【问题讨论】:

    标签: jquery pnotify


    【解决方案1】:

    您可以使用 PNotify.removeAll() 删除所有通知。

    【讨论】:

    • 知道如何删除所有通知,但不删除某些特定通知吗?
    • @baltusaj 每当您创建通知时,请设置一个名为 name 的属性,该属性对于每个通知都是唯一的。然后使用 PNotify.notices 列出所有通知,然后根据 if 条件,您可以通过调用 .remove 来删除该特定通知。例如:PNotify.notices[notice_to_be_removed].remove();
    猜你喜欢
    • 2016-06-09
    • 1970-01-01
    • 2012-11-26
    • 2018-12-07
    • 1970-01-01
    • 1970-01-01
    • 2017-11-22
    • 1970-01-01
    • 2021-08-22
    相关资源
    最近更新 更多