Page 1 of 1
When values change on a page- can we determine that with JS?
Posted: Mon Mar 04, 2013 2:35 pm
by HowardA
If a user changes some input value of a PUI screen, then selects some link(for instance) that would take them away from that page without saving the changed data, I'd like to be able to KNOW that the data had changed so I can put a popup that lets the user know his/her changes will be lost if they continue. Since the navigation doesn't bring them back to the server, is there a way with JavaScript within the PUI framework to do this? ("isDirty" )?
This link mentions doing something like this with Jquery or JS, but I'm not sure if any of the methods would work within the PUI environment or not.
http://stackoverflow.com/questions/5989 ... ed-on-an-h
Re: When values change on a page- can we determine that with JS?
Posted: Mon Mar 04, 2013 3:02 pm
by Scott Klement
By default, PUI tells the browser to warn the user when navigating away from a PUI or Genie screen. This is a feature you can disable in JavaScript (and, it's disabled in Atrium by default) but, unless you've done that, you should get a warning already.
If you wanted to write your own that only comes up if changes were made, you could do that in JavaScript. You'd have to write code that keeps track of whether changes have been made, and then check that code before any of the "exit" buttons or links are clicked.
For example, you could draw a box around all of your fields in the designer. Then select the "on change" event, and have it call a JavaScript function, maybe named something like citco.setChanged(). The setChanged() routine would set a flag (citco.changesFound, maybe) setting it to true if a change has been made.
The record format's onLoad event would need to set that flag back to false.
Then each of the exit buttons or links could call something named citco.checkChanged() which would check if that flag has been set to true, and if so would display a warning.
Does that make sense?