Skip to content

Instantly share code, notes, and snippets.

@Shadows-of-Fire
Last active October 17, 2018 18:25
Show Gist options
  • Save Shadows-of-Fire/293cd453bc47c18e2737487565f56453 to your computer and use it in GitHub Desktop.
Save Shadows-of-Fire/293cd453bc47c18e2737487565f56453 to your computer and use it in GitHub Desktop.

Your application will likely need to store data in order to accomplish functions that require communication between elements.

There are a few ways to do this. The easiest way is client-side data storage. This is accomplished by using HTML Web Storage, a string to string map in the browser's cache. There are two kinds of storage, localStorage and sessionStorage. Both are members of the root element window, and have two methods: getItem(String) and setItem(String, String).
The difference between local and session is that local will persist if the page is closed, while session data is cleared.

An example of this in app maker is having two buttons to save or load something from local storage into a text field. In this case, the current page is TestPage, and the text box is TextBox1.

Each button has an on click action. The top button saves the data to localStorage, via window.localStorage.setItem("tempData", app.pages.TestPage.descendants.TextBox1.value); as it's onClick action.
The lower button reads the data from storage into this box, via app.pages.TestPage.descendants.TextBox1.value = window.localStorage.getItem("tempData");.

To ensure this works, we can type a value into the box, save it using the save button, change the value, and hit load. It should return the box to the value that was present when save was clicked.

For more information on web storage, visit https://www.w3schools.com/html/html5_webstorage.asp

Information on Google Cloud SQL data storage will be coming eventually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment