nuIsSaved and Subform

Questions related to customising nuBuilder Forte with Javascript or PHP.

nuIsSaved and Subform

Postby Janusz » Mon Feb 24, 2020 7:49 pm

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.
Janusz
 
Posts: 287
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland

Re: nuIsSaved and Subform

Postby kev1n » Mon Feb 24, 2020 7:59 pm

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;
}
kev1n
 
Posts: 557
Joined: Mon Oct 15, 2018 2:13 am

Re: nuIsSaved and Subform

Postby Janusz » Mon Feb 24, 2020 9:50 pm

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.
Janusz
 
Posts: 287
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland

Re: nuIsSaved and Subform

Postby kev1n » Mon Feb 24, 2020 10:15 pm

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;
   
}
kev1n
 
Posts: 557
Joined: Mon Oct 15, 2018 2:13 am

Re: nuIsSaved and Subform

Postby kev1n » Tue Feb 25, 2020 4:59 pm

kev1n
 
Posts: 557
Joined: Mon Oct 15, 2018 2:13 am

Re: nuIsSaved and Subform

Postby admin » Sun Mar 01, 2020 9:02 am

Janusz and kev1n,

That is now fixed in the latest release.


Steve
admin
Site Admin
 
Posts: 3234
Joined: Mon Jun 15, 2009 9:53 am

Re: nuIsSaved and Subform

Postby Janusz » Tue Mar 03, 2020 5:16 am

Thanks Steve,
and to confirm nuIsSaved works OK with latest release.
Janusz
 
Posts: 287
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland

Re: nuIsSaved and Subform

Postby admin » Fri Mar 06, 2020 8:25 am

Thanks.
admin
Site Admin
 
Posts: 3234
Joined: Mon Jun 15, 2009 9:53 am


Return to Custom Code