Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Close all pnotify notifications when a specific notification shows up

Tags:

jquery

pnotify

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?

like image 532
GGio Avatar asked Dec 04 '22 06:12

GGio


1 Answers

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

like image 176
tarun1188 Avatar answered Feb 02 '23 00:02

tarun1188