Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8480581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:20:02+00:00 2026-06-10T19:20:02+00:00

I am having troubles trying to understand how to use Save before Exit plugin

  • 0

I am having troubles trying to understand how to use “Save before Exit” plugin with the Modal Page plugin in Oracle ApEx v4.1.1.

I basically would like to know how to attached the ‘X’ close button to the “Save before Exit” plugin when a user makes a change to a select list or text area field on the page (I also have classes associated to these fields), used within the modal page?

Here are links to the two plugins that I am trying to link together:

http://apex.oracle.com/pls/apex/f?p=46685:MODAL_PAGE:0

http://apex.oracle.com/pls/apex/f?p=46685:SAVE_BEFORE_EXIT:0:::::

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T19:20:04+00:00Added an answer on June 10, 2026 at 7:20 pm

    Important note: i tested this plugin with the latest version available: 3.0.2. The change detection routine there is modificationDetected, where in 3.0.0 it was changeDetected! Check which version you use!


    When i have to integrate things like these, i want to avoid altering provided code such as the plugin code. Doing this will break your stuff if you don’t remember in the future and install a new version (unless you’re actually fixing something of course).

    Create a dynamic action on the page that calls the modal dialog, fire on load:

    var default_colorbox_close = $.colorbox.close;
    $.colorbox.close = function(){
       iframejQ = $("iframe").get(0).contentWindow.apex.jQuery;
       iframeDoc = iframejQ($("iframe").get(0).contentWindow.document);
    
       apex.debug("Colorbox close attempt - check changes");
       var hasChange = iframeDoc.apex_save_before_exit("modificationDetected");
       apex.debug('Modal contains changes: '+hasChange);
    
       if(hasChange){
          $( "<div title='Unsaved changes!'>There are unsaved changes. Close the popup anyway?</div>" ).dialog({
             resizable: false,
             height:140,
             modal: true,
             stack: true,
             zIndex: 9999,
             buttons: {
                "Don't close": function() {
                   $(this).dialog( "close" );               
                },
                "Close": function() {               
                   iframeDoc.apex_save_before_exit("disableWarning")
                   default_colorbox_close();
                   $(this).dialog( "close" );
                }
             }
          });
       } else {
          apex.debug('Close modal with default colorbox close');
          default_colorbox_close();
       };
    };
    

    The save before exit plugin works by using the browser window.onbeforeunload event. It does trigger when the popup is closed (at least in FF it does), but by then it is way too late: the popup is gone and the markup too.
    My first thought was to simply tap that onbeforeunload event by redirecting the page to a generic page which would hold onload code to close the popup. The onbeforeunload would spring in action as soon as the redirect would be attempted. There would be no dynamic action or plugin altering. But oh well, i decided against that. (Note though: most of the code in this snippet would have to be reused in that case too, save change detection and dialog).
    Instead i choose to check for changes in the iframe document when a close event happens, and display a dialog, which can be modified too, and clearly indicates that you are performing an action on the popup and not on “the page” (which could be interpreted as the parent page of the modal).

    So what is needed is to catch the modal popup close event. Note that the plugin is based of the jQuery Colorbox plugin. The Skillbuilder modal does not provide a pre-close event and can not without altering the colorbox plugin.
    Colorbox provides a close option in the form of the “X” and also the ESC-key. I want to catch both(/all).
    I didn’t opt for unbinding the click on the X and binding a new click.

    • what i did first is save the default colorbox close event, and
      then override the default.

       var default_colorbox_close = $.colorbox.close;
       $.colorbox.close = function(){
      
    • Next up: this piece of code will get the jQuery instance of the modal
      page. I then fetch the document element of the page with this jquery
      instance

       iframejQ = $("iframe").get(0).contentWindow.apex.jQuery;
       iframeDoc = iframejQ($("iframe").get(0).contentWindow.document);
      
    • Next up is checking the iframe (modal popup) for changes

       var hasChange = iframeDoc.apex_save_before_exit("modificationDetected");
      
    • So if the page has changes, a warning has to be displayed. I do this
      by using jQuery-UI Dialog. It will have “Unsaved changes!” as title,
      and 2 buttons (“Don’t close” and “Close”). When closing, the save
      before exit plugin has to have its default warning disabled! If not,
      you’d still get prompted by the onbeforeunload message! Then the
      colorbox has to be closed (which will remove the iframe). Finally
      the dialog (prompt) has to be closed.

        if(hasChange){
           $( "<div title='Unsaved changes!'>There are unsaved changes. Close the popup anyway?</div>" ).dialog({
              resizable: false,
              height:140,
              modal: true,
              stack: true,
              zIndex: 9999,
              buttons: {
                 "Don't close": function() {
                    $(this).dialog( "close" );               
                 },
                 "Close": function() {               
                    iframeDoc.apex_save_before_exit("disableWarning")
                    default_colorbox_close();
                    $(this).dialog( "close" );
                 }
              }
           });
      
    • If there are no changes, then the modal can simply be closed.

        } else {
           apex.debug('Close modal with default colorbox close');
           default_colorbox_close();
        };
      

    Hope some of that sticks 😉

    Example on http://apex.oracle.com/pls/apex/f?p=11128:1


    Edit:
    And some big thanks to Dan McGhan for helping in the OTN thread 🙂
    https://forums.oracle.com/forums/thread.jspa?threadID=2434115&tstart=0

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to understand Oracle database's use of data type = number. I
I'm having trouble trying to understand how to use recursion with this problem. I'm
I'm having terrible trouble trying to understand python scoping rules. With the following script:
I am trying to understand JavaScript a little better and am having trouble creating
I'm having a bit of trouble trying to understand how WARP could potentially interact
I'm trying to understand the ControlStyle property in Delphi 2007, but I'm having trouble
I'm having troubles trying to find a solution, if any, to this: public class
Having troubles with items property of connected sortables. What I'm trying to do is
I'm having troubles with a syntax error when trying to create a function in
I'm trying to move some Excel-Data to MySQL, but having troubles with encoding. What

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.