I show notifications to users using the pnotify plugin. However, I want to delete the notification for all tabs if the user closes the notification on tab 1 by clicking the X icon.
I use localstorage for this, every time a new notification is displayed to the user, it is added to localStorage. When the user clicks the X icon, I do localStorage.removeItem(key) . How to listen to this event to close the notification on all tabs?
My listener is below:
$(window).bind('storage', function(e) {
I noticed that newValue turns to null if it was removed, this will theoretically work (not yet verified), but is it reliable in terms of whether it always returns null if removeItem was called to this element? What if the element value changes to null , it will trigger this event, since the value has changed correctly?
source share