Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Warn on Close: Getting handle on parent page

AnnelizeFJun 26 2024 — edited Jun 26 2024

I used John Snyder's application: All The Things That Pop Up for help on getting my dialog page to get a handle on the ‘top level APEX page’ so I can implement a Warn on Close message when changes has been made to a modal, and the user cancels a dialog via

  • Cancel Button
  • X
  • Escape

This is demonstrated in my application (AF_PLAYS | demo | demo_123) on page 9 (Warn before Closing Modal) by editing a customer row, making a change and closing the page without saving in one of the above ways.

This will open a modal page (p11) with which gets a handle on the top level APEX page as follows:

var theDialog$ = apex.util.getTopApex().jQuery(".ui-dialog-content").filter(function() { return $(this).find("iframe")[0].contentDocument.body === document.body; });

This works well as long as there is only the one dialog page being called from page 9

However, as demonstrated on page 10 (Warn before Closing: Multiple Modals) which also has a Inline Popup dialog, when calling the same modal page (p11) it throws a Javascript error:

TypeError: Cannot read properties of undefined (reading 'contentDocument')

I think this is because there is more than the one dialog with class ui-dialog-content and therefore multiple “iframes” on the parent page: #user_pop and #apex_dialog_1

I have tried changing the statements and although I don't get the JS error anymore it's still not getting the parent page:

  • var theDialog$ = apex.util.getTopApex().jQuery("apex_dialog_1.ui-dialog-content") …
  • var theDialog$ = apex.util.getTopApex().jQuery("ui-dialog-content.ui-widget-content.js-dialogReady") …
  • var theDialog$ = apex.util.getTopApex().jQuery(".ui-dialog-content").filter(function() { return $(this).find("iframe")[1] …

Any help on understanding how I would do this, would be appreciated!

Thanks

Annelize

This post has been answered by Karel Ekema on Jun 27 2024
Jump to Answer
Comments
Post Details
Added on Jun 26 2024
2 comments
265 views