Close Modal Dialog When Clicked Outside in Oracle APEX

Modal Dialog page in Oracle APEX by default can be closed my clicking the (x) icon/button on the top right corner of the modal page.

In this post I will be explaining, how to close the modal dialog when clicked outside.

Please follow the below steps to achieve this:

1) Define the following JavaScript function in the Function and Global Variable Declaration section on the parent page (The page from which the modal dialog page is being called/opened).

function closeModalDialogPage(element){

     $('.ui-widget-overlay').click(function(){
        $(element).dialog('close');
     });
   }

Note: If you’re going to be using this in more than one place, its better to define it either on the page 0 or in a global JavaScript file.

2) Create an open callback that will trigger the close dialog method when clicking outside the dialog. We have to set call the function when the dialog opens. Define the below code in the Attributes section of the Modal Dialog page.

open: function(event, ui) { closeModalDialogPage(this); }


Click here for DEMO

Happy CODING!!!

Thank you :)

Comments

Popular posts from this blog

Allow Only Number/Decimal values In a Number/Text Field Using JavaScript in Oracle APEX

Display and Edit CLOB Content in Oracle APEX

Copy the value of an Item to Clipboard in Oracle APEX