Andrew Kilburn
Andrew Kilburn

Reputation: 2251

Detect if Jquery Noty notification has been closed

Is there a way to detect if a JQuery Noty notification has been closed using JQuery itself?

I have a Noty notification on my homepage. I would like to detect when the notification has been closed. Can anyone help with this?

Noty:

var n = noty({
  layout: 'topCenter',
  theme: 'relax',
  type: 'information',
  force: false,
  text: 'This one worked',
  animation: {
    open: 'animated zoomIn', // Animate.css class names
    close: 'animated zoomOut', // Animate.css class names
  }
});

Upvotes: 0

Views: 587

Answers (1)

Andrew Kilburn
Andrew Kilburn

Reputation: 2251

There is a method called 'callback' in Noty. This is how I used it to detect on close:

var n = noty({
  layout: 'topCenter',
  theme: 'relax',
  type: 'information',
  force: false,
  text: 'This one worked',
  animation: {
    open: 'animated zoomIn', // Animate.css class names
    close: 'animated zoomOut', // Animate.css class names
  },
  callback: {
    onClose: function() {
      Cookies.set('ShowNoty', false);
    },
  },
});

Upvotes: 1

Related Questions