4 Replies Latest reply: Mar 20, 2013 4:26 AM by 894802 RSS

    How to use "Save Before Exit" plugin

    894802
      Hi Guys,

      I am having trouble using the "Save Before Exit" plugin. My requirement is simple, I just want to use the *"$(document).apex_save_before_exit('modificationDetected');"* method to display an alert message saying "This page has been modified" whenever the page is modified else display message "No changes made".

      Could you please help me on how to achieve this?

      Thanks,
      San
        • 1. Re: How to use "Save Before Exit" plugin
          Denes Kubicek
          This plugin has a very good document included in the installation directory and it explains it in details on how to use it.

          Denes Kubicek
          -------------------------------------------------------------------
          http://deneskubicek.blogspot.com/
          http://www.apress.com/9781430235125
          http://apex.oracle.com/pls/apex/f?p=31517:1
          http://www.amazon.de/Oracle-APEX-XE-Praxis/dp/3826655494
          -------------------------------------------------------------------
          • 2. Re: How to use "Save Before Exit" plugin
            894802
            Hi Denes,

            Thanks for your response. I have read the document. The plugin works fine but I want to display my own error message with Ok and Cancel button options. I tried to experiment with the "*$(document).apex_save_before_exit('modificationDetected');*" method. I added an advanced dynamic action to execute some Javascript code. The code is very simple as shown below.
            If ($(document).apex_save_before_exit('modificationDetected'))
            {
            alert("This page has been modified");
            }
            else
            {
            alert("No changes made");
            }
            This dynamic action has been attached to a button named "Test" but whenever I click on the button nothing happens irrespective of the page being modified or not. However, if I change the If condition in the Javascript code to
            If (1=1)
            {
            alert("This page has been modified");
            }
            else
            {
            alert("No changes made");
            }
            the dynamic action works.

            Do you have any idea what I might be missing?

            Your help is much appreciated.

            Thanks,
            San
            • 3. Re: How to use "Save Before Exit" plugin
              scott.wesley
              maybe check out what items might be modified... for starters:
                  modifiedItems = $(document).apex_save_before_exit('modifiedItems');
                  if (modifiedItems.length == 0) {
                      // no need to continue if no items modified
                      apex.debug('No changes identified');
                      return;
                  }
              • 4. Re: How to use "Save Before Exit" plugin
                894802
                Hi Scott,

                Thanks for your reply. I tried your code but could not get any output. I modified your code a little to catch javascript error. Below is the code I used
                try{
                 modifiedItems = $(document).apex_save_before_exit('modifiedItems');
                 alert('I guess you do exist')
                }
                catch(e){
                 alert('An error has occurred: '+e.message)
                }
                The error I am getting is *"An error has occurred: Object [object Object] has no method 'apex_save_before_exit'"*. Any idea what could be the issue?

                Thanks a lot for your help.

                San