How to Fire a Close Event on Dialog X Button Click

Search for a command to run...

No comments yet. Be the first to comment.
Oracle APEX already includes Font APEX as the default icon library for Universal Theme. In most cases, that is enough. But in one of my APEX apps, I needed a few icons that were not available there, s

Looking to give your Oracle APEX mobile app a modern, native feel? Here’s a quick hack: add a floating action button that stays anchored at the bottom corner just like in popular mobile apps. This sma

APEX 26.1 has been updated to the Universal Theme. While much of the attention in this release is on AI features, I think the UT improvements are just as important for developers like me who care abou

The apex_barcode package offers a PL/SQL API to generate various types of barcodes. You can output barcodes as SVG (Scalable Vector Graphics) values or as PNG file blobs, making it easy to embed them

Oracle APEX makes it easy to get data on screen fast, but often, the default tabular output isn’t enough. What if you want to highlight statuses, add icons, or display badges all without writing compl

By default, the X button on dialog pages cancels and closes the dialog when clicked. Today, I came across a situation where I needed to trigger a dialog close dynamic action on the parent page whenever the dialog is closed. However, I can't rely on users always clicking my dialog close button. I could remove the X button, but I want to keep it consistent with all other dialogs.
function customEvent(event, data) {
apex.event.trigger(document, event, data);
}
close: function() {
customEvent('customDialogClose', {modalPageId: 'MODAL_CLOSE_FIXED'});
}
This overrides the default close behavior and triggers a custom event named "customDialogClose" when the dialog is closed, including when the "X" button is clicked
Event: Custom
Custom Event: customDialogClose
Selection Type: JavaScript Expression
JavaScript Expression: document
This approach will handle both the "X" button click and other cancellation methods, such as using a dynamic action with a "Cancel Dialog" action.
The custom event will be triggered on the parent page, allowing you to perform actions after the dialog is closed.
You can use the data attribute (modalPageId in the example) to differentiate between multiple modal dialogs if needed.