Save Changes Reminder for IRs and Custom Tabular Forms with PPR

I have been implementing the SkillBuilders Save Before Exit Apex Plugin, which has been working well for the majority of pages in my application. The two situation that it doesn't appear to cater for are when paginating in custom tabular forms where Partial Page Refresh (PPR) pagination has been used. In a standard report region this feature can be removed, but in IRs they cannot.

I have written a small piece of code that will intercept the pagination function for PPRs and and allow you add some of your own JS. An example can be found here.

And here's how I did it:

1. In the page header or in a region on page 0, add the following code:

<script type="text/javascript">

var p_changes = false;

$(document).ready(function() {
p_changes = true;
function(event) {
if (p_changes) {
if (confirm('"SAVE_CHANGES_MSG"')) {
p_changes = false;
else {


2. Create a shortcut call SAVE_CHANGES_MSG

Are you sure you want to leave this page?\n\nYou have made changes to this page. If you navigate away from this page without first saving your data, the changes will be lost.\n\nClick OK to leave this page, or Cancel to stay on this page.