bootstrap-notify
bootstrap-notify copied to clipboard
Close hyperlinked notification when clicked
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();
});
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;
}
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...
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.
Any updates on this?