bootstrap-notify icon indicating copy to clipboard operation
bootstrap-notify copied to clipboard

Close hyperlinked notification when clicked

Open sirianni opened this issue 9 years ago • 4 comments

It would be nice to provide an option to close a hyperlinked notification (i.e. one using the url option) when clicked. When the hyperlink is navigating within the single page application (using target="_self"), this would be common behavior.

I'm currently implementing this as follows, but it would be nice to have this functionality first-class in the plugin.

var notification = $.notify(...);       
notification.$ele.on('click', 'a[data-notify="url"]', function() {
  notification.close();
});

sirianni avatar Apr 29 '15 15:04 sirianni

Would you rather have on click event or an option to close on click? I don't think I would personally code it to limit it where you would have to use url for it to work. I think I like the idea of an onClick event.

For example click event would look like this

$.notify('hello World', {
   onClick: function() {
      this.close();
   }
});

close option would look like

$.notify('Close on Click', {
   closeOnClick: true;
}

mouse0270 avatar Apr 29 '15 15:04 mouse0270

I would probably lean towards onClick because it allows more flexibility. If you're going to allow this for non-URL-based notifications it would seem necessary to allow for changing the CSS cursor property in this case...

sirianni avatar Apr 29 '15 15:04 sirianni

I can make the cursor a property. That seems fine.

This would be a perfect time to add more events such as mouseenter and mouseleave. I have been meaning to add them for a while.

mouse0270 avatar Apr 29 '15 15:04 mouse0270

Any updates on this?

shahimclt avatar Feb 01 '18 10:02 shahimclt