Session resume

back edit
  1. Type something in the field
  2. Click on [back]
  3. Click on [demo] and come back to this page
  4. Field values are persisted

<form>
  <label for="title">Title</label>
  <input name="title" id="title" autofocus class="js-session-resumable form-control mt-1 width-full mb-2" type="text">
  <label for="content">Content</label>
  <textarea name="content" id="content" class="js-session-resumable form-control mt-1 width-full" rows="5"></textarea>
</form>

When field values are restored, a custom event called session:resume is dispatched for each field. See console.

document.addEventListener('session:resume', console.log)