Notify.js清除旧通知
Notify.js clear old notifications
我正在使用Notify.js在我的网站上显示通知。我遇到了一个问题,我添加通知会显示它们,然后,如果我想显示不同的通知并添加它,我也会看到旧的通知。工作流程为:
- 用户输入数据
- 用户按下按钮
- 数据已验证
- 已添加错误通知
- 继续,直到一切都正确
为了添加通知,我使用以下内容:
var noteOption = {
// whether to hide the notification on click
clickToHide : true,
// whether to auto-hide the notification
autoHide : false,
globalPosition : 'bottom right',
// default style
style : 'bootstrap',
// default class (string or [string])
className : 'error',
// show animation
showAnimation : 'slideDown',
// show animation duration
showDuration : 400,
// hide animation
hideAnimation : 'slideUp',
// hide animation duration
hideDuration : 200,
// padding between element and notification
gap : 10
}
var note = "My Error Message"
$.notify.defaults(noteOption);
$.notify(note, "error");
所以现在的实际问题是,在添加新通知之前,我如何清除通知?
谢谢,
Liron
这是因为您调用的函数总是返回Notification的新实例最好的方法是清除旧的通知容器:
$('.notifyjs-corner').empty();
遗憾的是,它们没有类似的功能:$.singletonNotify()
这对我很有效:
$.notifyClose();
$.notify({...});
https://github.com/mouse0270/bootstrap-notify/issues/136#issuecomment-204051563
相关文章:
- document.open/document.write没有正确地清除chrome中的文档——这是chrome的错误吗
- 单击jquery清除输入值
- Firebase2(Firebase.google.com)推送通知-从外部管理
- 如何在Microsoft VirtualEarth 6.3中使用纯javascript清除整个形状层
- 清除以前的$_GET值或不获取仅隐藏字段的值
- 无法在窗口内使用rootScope.通知
- JS,用于播放提示音以通知未按预期工作
- Javascript清除缓存以清除基本身份验证凭据
- 单击Chrome通知后,转到已打开的选项卡
- Windows Azure通知中心错误
- 清除启动日期选取器值
- 在 SlickGrid 中编辑后,根据不同列中的另一个单元格清除单元格
- php页面,该页面在清除值后接受输入
- 清除数据并将旧值附加到文本框中
- 单击按钮清除推送通知
- Notify.js清除旧通知
- Phonegap应用程序清除推送通知不起作用
- 清除通知,点击/切换()
- 清除系统通知
- Azure移动服务推送磁贴通知和清除磁贴属性