【发布时间】:2018-07-19 08:09:43
【问题描述】:
有没有办法防止 toastr 在单个页面上显示同一消息的多个实例。我正在使用一页来满足我的添加和更新功能。这是我的代码的 sn-p
window.toastr.options = {
"toastClass": "toast-success-create-campaign",
"closeButton": false,
"debug": false,
"newestOnTop": true,
"progressBar": false,
"positionClass": "toast-top-center",
"onclick": null,
"showDuration": "300",
"hideDuration": "1000",
"timeOut": "5000",
"extendedTimeOut": "1000",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut",
"maxOpened":1,
"preventOpenDuplicates": true
}
$('.btn-add').on('click',function(){
window.toastr.success('Add Called','Success!');
})
$('.btn-update').on('click',function(){
window.toastr.success('Update Called','Success!');
})
似乎 toastr 保留了所有 toast 调用的缓存,这就是为什么当我尝试执行该函数时,它会相互叠加而不是只显示一个。如何修改我的代码以获得我想要的输出。
【问题讨论】: