Created
April 13, 2011 17:17
-
-
Save chriscoyier/917936 to your computer and use it in GitHub Desktop.
This file contains 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
// Save all data, on some kind of event | |
localStorage.setItem("doesHaveData", "yeahBaby"); | |
var data = $("#contest-vote").serializeArray(); | |
jQuery.each(data, function(i, obj) { | |
localStorage.setItem(obj.name, obj.value); | |
}); | |
// Get all data back, test on page load | |
if (localStorage.getItem("doesHaveData")) { | |
var data = $("#contest-vote").serializeArray(); | |
jQuery.each(data, function(i, obj) { | |
$("[name='"+ obj.name +"']").val(localStorage.getItem(obj.name)); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment