Page 1 of 1

How to tell if the form has been edited in Javascript

Posted: Sat Jul 21, 2018 12:24 am
by alf1976
Hi

What the is easiest way to tell if a form has been edited via Javascript?

i use nuAddActionButton to add the ability to run a report from an 'edit form' but i only want the report to run if the data is 'saved'. So basically when the save button is not red.

nuHasBeenEdited(). nuHasNotBeenEdited() only alters the status. i tried using nuIsSaved() in the Action Button function but that just kept returning false and i couldn't see anything in nuCurrentProperties. Any ideas?

Andrew

Re: How to tell if the form has been edited in Javascript

Posted: Sat Jul 21, 2018 4:09 am
by toms
alf1976 wrote: i tried using nuIsSaved() in the Action Button function but that just kept returning false
Hi,

nuIsSaved() doesn't seem to work for me either (always returns false).

Maybe a workaround: Check if the save button is not red:

Code: Select all

if (!$('#nuSaveButton.nuSaveButtonEdited').length) {
  // run report
}

Re: How to tell if the form has been edited in Javascript

Posted: Sat Jul 21, 2018 7:08 pm
by alf1976
Hi Toms,

thanks, that is a useful workaround.

i can get nuIsSaved() to return true, but only when it placed in the code section that runs when the form opens . ie

Code: Select all

if(nuFormType() == 'edit')
{
    if(nuIsSaved()===true)
    {
      // do something...
    }
    if (nuIsNewRecord()===true)
    {
        // do something 
    }
}
The wiki does say 'Used to tell if the current Edit Form has just been Saved'. So i suppose it does do what it says.

Re: How to tell if the form has been edited in Javascript

Posted: Sun Jul 22, 2018 11:38 pm
by admin
alf1976,

I believed I have fixed it now.

Let me know if nuIsSaved() works for you now.

Steven