Tuesday, December 30, 2008

Wait, Wait! Don't forget to save...

Ever want to display a warning message to your users if they try to leave a page without saving their changes? Until I took a look at this forum post, I'd never really thought much about how to implement this functionality. But with jQuery and Jon St. John's code to help me get started, it wasn't too hard.

The trick is creating reusable/generic code and the following is a start toward that end. Please let me know of any issues/suggestions so that I can make updates. Also, keep in mind that this should not be implemented on VERY page - just the important ones! ;)

I "retrofitted" this previous example to demonstrate. Try modifying a value in the form and then use one of the links on the left to leave the page - even try closing the page. Notice the buttons still work as they should.

Here's how to get it working...

  1. Install jQuery in ApEx.
  2. Place the following code in the HTML Header of the page.
    
     
Post a Comment