In Oracle Apex, you have created a modal dialog page and you want to disable the escape key to prevent close dialog window. To achieve this, follow these simple steps:
Disable ESC Key to Prevent Close Dialog
Open your dialog page in Oracle Apex. Then right side in the property palette, scroll down to the Dialog
section and add the following code to the Attribute
property:
closeOnEscape:false
Below is the screenshot for your reference:
Now save the changes and run its parent page to test and you will see, on Escape key press the dialog will not close.
But what if the user will close the dialog from the title bar (X) close button? Maybe you want the user to close the dialog via close/cancel button only, because you may have written some code on it. To disable the title bar close (X) button, follow these steps:
Hide Dialog Window Title Bar Close (X) Button
Open the parent page from where you are opening the dialog page and add the following CSS code in the Inline CSS
property section:
.no-close .ui-dialog-titlebar-close { display: none; }
Save the changes to the parent page.
Now open your dialog page and in the Dialog
property section add the no-close
class in the CSS Classes
property. You will find this property below the Attribute
property, you can see it in the above image.
Save the changes and to test it at runtime, refresh the parent page first, and then open the dialog, you will not see the title bar close (X) button, as shown in the below image:
Now the user has to press the Cancel
or Apply Changes
button to close the dialog. The user will not be able to close using the Escape key or via the title bar close button.
Related Tutorials:
- Oracle Apex: Display Confirm Dialogs Using JavaScript
- Oracle Apex: Change Dialog Title Dynamically Examples
- Oracle Apex – On Close Dialog Refresh Parent Page Regions
Thanks!
Hi I tried the above steps but it did not worked.
This is the tested method in Oracle Apex 18.1 onwards. What is the version of your Oracle Apex?
The modal parent is what controls the ui-dialog-titlebar-close is ready to react of it, thats why You should config in the parent page? I used // Hide button X
var button = parent.$('.ui-dialog-titlebar-close'); //get the button
button.hide('fast'); //hide the button
But it still leaves a glimpsy of it before it is hidden
Yes, try to use the above CSS in parent page, it should be ok.
Thank you for this post. I have been searching the answer for this for 5 hours. Tried MANY different methods. Finally, you have the ABSOLUTE solution. It is working perfectly. Thank you very much.
not working in latest version any other solution please
Hi I tried the above steps but it did not worked, it just worked disable ESC Key to Prevent Close Dialog.
Not working in Application Express 21.1 any other solution please "Hide Dialog Window Title Bar Close (X) Button"