Skip to main content

Hiding Alerts programmatically

Although you can hide all the alerts and integrate your own alerts with Using Your Own Alerts recipe, it may not be ideal when you only want to hide certain alerts while keeping some others.


As part of version 1.8, we have added ability to hide alerts programmatically as such:

window
.hapi
.alert
.service
.hide(
window
.hapi
.alert
.utils
.alertKeys
.productRemoveFromBasket
)

For example the above alert can be hidden upon success event after removal of a basket item as such:

window
.hapi
.basket
.service
.removeProductOrContractById
.onSuccess(() => {
window
.hapi
.alert
.service
.hide(
window
.hapi
.alert
.utils
.alertKeys
.productRemoveFromBasket
)
})