Created
January 6, 2013 12:50
-
-
Save glynrob/4466921 to your computer and use it in GitHub Desktop.
Web storage list example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.addEventListener("DOMContentLoaded", loadSavedData, false);// load locally saved data when the page opens | |
// get the locally saved data | |
function loadSavedData(){ | |
savedData = localStorage.getItem("data"); // get data from local storage | |
if (savedData && savedData != null) { // if not empty | |
savedData = JSON.parse(savedData); // get data from returned json string | |
savedData = savedData['dataToSave']; // set savedData from dataToSave item | |
showListItems();// Generate the list items and display | |
showLocalData();// show data | |
} else { | |
savedData = []; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment