Last active
March 3, 2017 11:23
-
-
Save CezaryDanielNowak/85302c1d3323e951e3885bcedaa7c10b to your computer and use it in GitHub Desktop.
Form: save it!
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
// select form in Inspector and call: | |
localStorage._formData_ = JSON.stringify(Array.from($0.querySelectorAll('input')).map((el) => el.value)); | |
// to restore data: | |
const _formData_ = JSON.parse(localStorage._formData_) || []; | |
Array.from($0.querySelectorAll('input')).forEach((input, id) => { | |
input.value = _formData_[id]; | |
var event = document.createEvent("HTMLEvents"); | |
event.initEvent("input", true, true); | |
input.dispatchEvent(event); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment