mouse0270 / bootstrap-notify

Turns standard Bootstrap alerts into "Growl-like" notifications.
http://bootstrap-notify.remabledesigns.com/
MIT License
2.25k stars 641 forks source link

Duplicate Notifications After Consequent AJAX Calls #157

Open monsieur-ricky opened 7 years ago

monsieur-ricky commented 7 years ago

Hi,

I'm using the most recent release of Bootstrap Notify (v3.1.5) to show status messages after an AJAX call. It works as expected in the first call. After the first execution, every time the notify is called, its shows the previous notifications message. Example:

How can i solve this issue?

$.notify({ icon: icon, title: title, message: message }, { type: type, allow_dismiss: true, newest_on_top: false, placement: { from: "top", align: "right" }, offset: 20, spacing: 10, z_index: 100000, delay: delay, timer: 1000, mouse_over: true, animate: { enter: 'animated fadeInDown', exit: 'animated fadeOutUp' } });

GuruWithin commented 7 years ago

I am getting the similar issue. Notification gets doubled on every call.

adrox37 commented 7 years ago

I am also experiencing the same issue

bwhitley commented 7 years ago

Same exact issue I'm having. Is there a fix or an answer to how to use this plugin in this scenario? I have noticed that if i refresh the page, the issue doesn't raise it's ugly head, but it's not the way I want to do this!

bwhitley commented 7 years ago

Sorry to flood with comments about this issue, but I would really like to use this! However, I cannot figure out a solution to this problem. I'm having the same issue that ricky2k7 originally commented on. Please, please let me (us) know if this is a bug, if there is a workaround, etc.

mouse0270 commented 7 years ago

Can someone send me an example of this issue. I am not able to replicate it, sorry.

bwhitley commented 7 years ago

I finally solved my issue with this not too long after I posted my last comment. I've been a developer for over 20 years, but fairly new to the front-end world so I'm sure it was the way that I was using it.

I was generating a $.notify("...") within the success promise of my ajax calls and for some reason, on successive calls, the notification bubble would increase by one each time. I was debugging this issue and sure enough, if it was the third time, 3 events were getting fired.

What I did was pulled the $.notify("...") out from the promise and instead, called a method that then did a $.notify("..."). This fixed my issue, but I don't know why.

GuruWithin commented 7 years ago

For a more simple solution just add $.notifyClose(); before the $.notify() call. This is clear all the pending stacks and instantiates new.