Question

I'm currently implementing a Master Save behaviour for a master layout that holds 7 tabs.

Essentially, when the Save button on the master layout is clicked, I want it so that each tab saves itself (complete), and then reports to the master layout that it has saved (again, complete)

What I am stuck on is, I'd like to have a truth table in the corresponding JS file for the master layout, which keeps track of which of the 7 tabs have been saved so it can report back to the user that the save has completed.

To generalise: Truth tables/2D arrays in Javascript, where they at?

Thanks in advance.

Was it helpful?

Solution

You can keep track of whether each of the 7 tabs has been saved with an array of booleans:

var tabSaveTable = [false,false,false,false,false,false,false];

Then, whenever a given tab is saved, you can just mark its slot as true and whenever it is changed (so it needs to be saved again), its slot can be set to false. For example to mark tab3 as saved (assuming your tabs are numbered starting with 0), you would just set:

tabSaveTable[3] = true;

If tab3 gets changed and needs saving again, you would set:

tabSaveTable[3] = false;

This is the part of your question that I think I followed. If there is more to it, please clarify. I don't understand why you would need a 2D array for this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top