4

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?

GGio
  • 7,563
  • 11
  • 44
  • 81

1 Answers1

16

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

tarun1188
  • 178
  • 2
  • 7
  • any idea how to remove all notifications but not some specific ones? – Uthman May 15 '15 at 00:58
  • @baltusaj Whenever you create a notification set an attribute called name which will be unique for each notification. Then use PNotify.notices to list all the notices, Then based on an if condition you can remove that particular notice by calling .remove on it. eg: PNotify.notices[notice_to_be_removed].remove(); – tarun1188 Jun 11 '15 at 15:15