I have a slightly odd use case for Fancybox 6. I want to open a popup and prevent it from closing.
I can disable the Close button easily enough as an option but I can't seem to remap the keyboard shortcuts using the keyboard options. Even if I get that to work, users can still click the grey overlay background to close the popup and I'm not sure if I can prevent this.
I can hook into the "on" close event but I cannot prevent the close from happening even if I use return false;
:
Fancybox.show([{
src : "#modal",
closeButton : false,
}], {
on: {
"close": (fancybox, eventName) => {
// Something here to precent closing ...
});
Any ideas?
To prevent closing the popup in Fancybox 6, you can use this:
Fancybox.show(
[
{
src: "#modal",
},
],
{
backdropClick: false, // prevent closing on overlay click
closeButton: false, // hide close button
keyboard: { Escape: null } // disable ESC key closing
}
);
For more information on keyboard options, check here:
https://fancyapps.com/fancybox/api/options/#keyboard