I'm using Notify.js to show notifications on my site. I encountered a problem, where I add notifications show them and then, if I want to show different notification and add it as well, I see the old notifications as well. The work flow is:
In order to add a notification I use the following:
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");
So now the actual question, how do I clear the notifications before adding new ones?
Thanks,
Liron
This is because the function you call always return a new instance of Notification The best way is clear the old notification container:
$('.notifyjs-corner').empty();
Regretly they don't have function like: $.singletonNotify()
This worked for me:
$.notifyClose();
$.notify({...});
https://github.com/mouse0270/bootstrap-notify/issues/136#issuecomment-204051563
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With