Search code examples
oracle-databaseoracle-apexoracle-apex-5

Confirmation before closing a modal dialog page in Apex 5.0


I am trying to create a simple confirmation ("Do you want to close this window?") when closing a modal dialog page with the (X)-button.

What would be the most efficient way to implement this in Apex 5.0?

I tried to implement a solution using the dialog closed event, this seemed to have had no effects on closing the dialog with the (X)-button, however.


Solution

  • Try to create a dynamic action, on page load, in your modal page with that code:

    Your da should execute a javascript code:

    var button = parent.$('.ui-dialog-titlebar-close'); //get the button
    button.unbind(); //remove the behavior
    
    //put another behavior to the button
    button.on('click', function() {
       apex.message.confirm( "Your message here", function( okPressed ) { 
          if( okPressed ) {
              apex.navigation.dialog.cancel(true);
          }
       });
    });
    

    Try to confirm if the "X" button have the css class "ui-dialog-titlebar-close", they can change between versions of apex. If necessary, update the first line of the code with the correct class.