Search code examples
javascriptjqueryhtmloracle-apex-5.1

Close modal inline dialog by clicking on button in sub-region and prevent it from re-opening


I've created a region, let's call it Notifications with Static ID: P1_NOTIFICATIONS, set its Template to Inline Dialog and added a sub-region called row-01 without any Static ID.

row-01 has a button OK with P1_MODAL_OK ID and the following Behavior: Action: Redirect to URL, Target: javascript:apex.navigation.modal.close(true,["P1_NOTIFICATIONS"]) or Target: javascript:apex.navigation.modal.close(true).

Neither JS API calls seem to work, modal doesn't close on clicking my button.

Tried also a dynamic action to Hide the P1_NOTIFICATIONS region, but it only hides its content, doesn't close the modal itself with all the overlays and stuff. The header and empty body are still visible.

Also there's an [x] Close button in the header, but I need to hide it. I also can't find its action, the script it calls to close the modal inline dialog region.

How to close the modal from my P1_MODAL_OK custom button? And how to catch the action triggered by the [x] button from modals header?

EDIT 1: openModal('P1_NOTIFICATIONS') works as well as closeModal('P1_NOTIFICATIONS'). The second solves my problem.

Update 2024

I no longer use APEX nor I follow this tools updates. This solution could've been made obsolete. Feel free to post Q&As for newer versions in a new thread.


Solution

  • To close modal inline dialog region, create a Redirect to URL button with the following call in target: javascript:closeModal('P1_NOTIFICATIONS'), where P1_NOTIFICATIONS is region's Static ID.