Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
Jenny Swift21,999 Points
How to save the entire state of a web application
There's a lot of code there, so I don't expect you to read it all, but I think being able to see the application might help you to see what I am trying to achieve.
I would have thought that learning how to save the state of a web application would be a popular topic to learn, and easy to find a tutorial about, because web apps are so common, and who wants to lose their data? But it surprises me it's hard to find. Maybe I'm missing something?
Anyway, can anyone please point me in the right direction of what I need to study, or resources where I can find answers to these things, or perhaps show me the code I would need in my app to prevent me losing my data on page refresh?
In case saving the entire state of the application isn't possible and I need to somehow do it individually for each piece of data, examples of those pieces of data I would want to save are:
When the user clicks on either 'new expense' or 'new income', and enters values into the inputs, I would want to keep those values, and then when the page is refreshed, I'm guessing I would somehow add all those inputs to the page with their corresponding values.
When the user adds categories, to save them, and once again, have them still there on page refresh.
Likewise when the user enters a budget.
And I would also want the page to remember after page refresh whether the expense or income was given the class 'reconciled', and if yes, for its reconciled box (the box with the capital R) to still be green on page refresh.
Sean T. Unwin28,690 Points
If it`s strictly online then you could go with a server-side db such as mySQL and similar, or something like MongoDB.
I suppose if you did not want to go heavily with server-side scripts and such, you could save pertinent information in JSON files on the server, but that could lead to a lot of overhead in the way of file size, number of files and speed of accessibility, not to mention creating an engine to iterate through data, save and delete data, etc..