Close all pnotify notifications when a specific notification shows up

GGio picture GGio · May 28, 2014 · Viewed 11.4k times · Source

I am using pnotify plugin. My code is as follows:

$('.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
      });
   }
});

My question is, how can I make all other visible notifications on page go away when this notification shows up on .input_elements change event. Is there an option on pnotify that makes it go away if another is opened?

Answer

tarun1188 picture tarun1188 · Sep 10, 2014

You can use PNotify.removeAll() to remove all the notifications.