When values change on a page- can we determine that with JS?

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
HowardA
Profound User
Posts: 29
Joined: Fri Feb 08, 2013 8:34 am
First Name: howard
Last Name: Arner
Company Name: Citco Sys
State / Province: Georgia
Country: United States
Contact:

When values change on a page- can we determine that with JS?

Post 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
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: When values change on a page- can we determine that with JS?

Post 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?
Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests