I have implemented a feature using session storage to control the display of a modal on first page load. As I am not familiar with using cookies, I opted for session storage instead.
Within the modal, I dynamically change the header and close button upon the first closure, transforming it from a "getting started" modal to a "help modal".
My goal is to restrict the ability to close the modal using the esc
key when the session storage is not yet configured and the modal is in "getting started" mode. However, once the modal is reopened as a "help modal", the esc
event should be enabled.
Currently, this functionality is only working at 50% capacity - initially, the esc
key cannot be used, even after switching to the "help" version. Additionally, reloading the page allows the esc
key to function properly.
In the code snippet below, the else
block handles the case where session storage is not set:
} else {
// show the help modal
$('#help').modal({
keyboard: false
});
$('#help').modal('show');
$('#help').on('hidden.bs.modal', function (e) {
keyboard: true
})
}
According to the documentation (https://getbootstrap.com/docs/4.0/components/modal/#events), the .on('hidden.bs.modal'
event is triggered when the modal has finished being hidden from the user.
Can someone suggest which event handler I should use to achieve the desired functionality?