How to access to the notification when onDidClick happens


I read the related topics and I tried to use notification inside the onDidClick function but it throws an error saying that notification is not defined.

I tried to read the documentation but it says that the NotificationManager returns a NotificationElement and the link returns a 404. Probable it should redirect to Notification?


The NotificationManager API can be accessed through atom.notifications.

Where did you find the dead link?


Yup, I know I can access it with atom.notifications but I was looking for any other alternative without iterating the loop. Someting like this:

buttons: [
     text: 'OK',
     onDidClick: () => {

The broken links can be found in NotificationManager API on the adding notification methods on onDidClick description.


Do you just want to be able to click a button to dismiss it? Because the notifications will do that on their own if options.dismissable is true.


But I want to perform an action when clicking the Cancel button and it should close the notification.


And what code are you using to make this happen?


Assign the notification to a variable, you can then dismiss()it.


notification = atom.notifications.addSuccess(
  "Close this notification",
  dismissable: true,
  buttons: [
      text: "Close"
      onDidClick: ->


@DamnedScholar The code I have is like the example shown by @idleberg.

Assigning the notification a variable worked. Thanks!