REMINDER:
On December 1, 2018, this forum will be closed to new posts and responses. After that date, you will still be able to view and search the forum. New discussions should take place in the IBM Developer Answers forum.



Feb 27, 2017, 11:25 AM
69 Posts

how to detect a dirty xPage

  • Category: Dojo and Client Side JavaScript
  • Platform: Windows
  • Release: 8.5.3
  • Role: Developer
  • Tags:
  • Replies: 2

I have a requirement to stop a user from leaving an xPage with unsaved changes, and give them the option to go back and save their changes.  I have the enableModifiedFlag turned on, which works if they try to close the browser tab or the browser itself, but doesn't work anywhere else.  I've also tried this solution: https://innerringsolutions.wordpress.com/2012/08/31/dealing-with-those-dirty-xpages/

But that doesn't work either.  Does anyone have a good solution to this problem???

Thanks in advance!

Feb 27, 2017, 2:07 PM
69 Posts
this works on a button, still need a solution for closing the tab

Ok, this works in a button:

if (XSP._isDirty()){

  if (confirm ("Are you sure you want to navigate away from this page?")){

    XSP._setDirty(false,"");

    return true

  }else{

    return false;

  }

I still need a good solution for closing the tab or the browser.  enableModifiedFlag will prompt the user, but it will not use the message I enter!

 


REMINDER:
On December 1, 2018, this forum will be closed to new posts and responses. After that date, you will still be able to view and search the forum. New discussions should take place in the IBM Developer Answers forum.