How to handle the modal closing event in Twitter Bootstrap?
Prerequisite Knowledge: Bootstrap 4 | Modal
The Bootstrap Events are: show.bs.modal, shown.bs.modal, hide.bs.modal, hidden.bs.modal etc. Out of all these events, we are interested in the hide.bs.modal and hidden.bs.modal events.
- hide.bs.modal: This event is fired immediately when the hide instance method has been called.
- hidden.bs.modal: This event is fired when the modal has finished being hidden from the user and will then wait for CSS transitions to complete.
Before Clicking the Button:
After Clicking the Button:
On closing modal, observe the console:
So when modal is closed, we successfully handle it using
- Fire an output in the console
- Alert the user