Page 1 of 1

nuIsSaved and Subform

Posted: Mon Feb 24, 2020 11:19 am
by Janusz
Hi,
When I add a raw to the suborm then the Save button on the main form is chaging to red but nuIsSaved() function shows "true".
When I modify the main form then nuIsSaved() works OK.

As quick fix I can probably use the button class to check the status:
as after adding new raw it changes the class

Code: Select all

from
class="nuActionButton"
to
class="nuActionButton nuSaveButtonEdited"
how to make a check in JS if nuSaveButtonEdited is present or not in the class.

Re: nuIsSaved and Subform

Posted: Mon Feb 24, 2020 11:29 am
by kev1n
Janusz wrote:Hi,
When I add a raw to the suborm then the Save button on the main form is chaging to red but nuIsSaved() function shows "true".
How is the row added? Manually or by script?
Janusz wrote:how to make a check in JS if nuSaveButtonEdited is present or not in the class.
This function will return true, if the button is red, otherwise false.

Code: Select all

function saveButtonEdited() {
    return $('#nuSaveButton.nuSaveButtonEdited').length > 0;
}

Re: nuIsSaved and Subform

Posted: Mon Feb 24, 2020 1:20 pm
by Janusz
Hi,
Thanks for reply it works OK.
Another possibility which I used in the menatime is to check the color

Code: Select all

function nuIsSaved2() {
var x1=$('#nuSaveButton').css("background-color");
if (x1=="rgb(255, 0, 0)") {return 0;}
return 1;
}
Regarding the subform - it's quite specyfic - with lookup and display fields and no edit fields.

Re: nuIsSaved and Subform

Posted: Mon Feb 24, 2020 1:45 pm
by kev1n
nuFORM.edited seems to work more reliable:

Code: Select all

if (nuFORM.edited) {
    alert('button should be red');
} else
    alert('button should be blue'); 
}
@Steven: There's probably a window.nuSAVED = false; missing in nuHasBeenEdited()

Code: Select all

function nuHasBeenEdited(){
	
	$('#nuSaveButton').addClass('nuSaveButtonEdited');
	nuFORM.edited	= true;
	window.nuSAVED	= false; // missing?
}

function nuHasNotBeenEdited(){
	
	$('#nuSaveButton').removeClass('nuSaveButtonEdited');
	nuFORM.edited	= false;
	window.nuSAVED	= true;
	
}

Re: nuIsSaved and Subform

Posted: Tue Feb 25, 2020 8:29 am
by kev1n

Re: nuIsSaved and Subform

Posted: Sun Mar 01, 2020 12:32 am
by admin
Janusz and kev1n,

That is now fixed in the latest release.


Steve

Re: nuIsSaved and Subform

Posted: Mon Mar 02, 2020 8:46 pm
by Janusz
Thanks Steve,
and to confirm nuIsSaved works OK with latest release.

Re: nuIsSaved and Subform

Posted: Thu Mar 05, 2020 11:55 pm
by admin
Thanks.