If I set enableModifiedFlag property to true on my Custom Control; I see the following code at the bottom of generated Page source.
Everything works fine when user m
On click of the button, use below CSJS: XSP._setDirty(false,"")
That'll make the document as non dirty and let user navigate to other page.
By using XSP._isDirty()
from CSJS you can get true if any field was modified or false if no changes were done to your form.
So I added this block of code to my button under CSJS to display same default alert from XPages:
if (XSP._isDirty()){
if (confirm ("Are you sure you want to navigate away from this page?" + "\n" + "\n" +
"This document may contain unsaved changes." + "\n" + "\n" +
"Press OK to continue, or Cancel to stay on the current page.")){
return true;
}else{
return false;
}
} else {
return true;
}