Thanks to visit codestin.com
Credit goes to github.com

Skip to content

rsvzuiun/form-storage

Repository files navigation

English | 日本語

form-storage

Library to save form contents to LocalStorage

https://github.com/appleple/form-storage has not been maintained since 2020, so I made it.

Installation

npm

npm install git+https://github.com/rsvzuiun/form-storage.git
import FormStorage from 'form-storage';

umd

Copy dist/index.umd.js to your desired name.

<script src="path-to-index.umd.js"></script>

umd (CDN)

<script defer src="https://cdn.jsdelivr.net/gh/rsvzuiun/form-storage/dist/index.umd.js"></script>

Usage

const storage = new FormStorage("form",
{
  name: "unique-name",
  includes: ['[class="in"]'],
  ignores: ['[class="out"]']
});
  • FormStorage.constructor()
    • 1st argument: CSS selectors to target HTMLFormElement
    • 2nd argument:
      • name: Key when savig to LocalStorage
      • ignores: Array of CSS selectors to ignore Element
      • includes: Array of CSS selectors to include Element
  • storage.save(): Save the current form content to LocalStorage
  • storage.apply(): Load the state from LocalStorage and apply it to the form
  • storage.clear(): Remove the state from LocalStorage
  • storage.addEventListener(...): Apply addEventListener for HTMLFormElement
  • storage.addChildrenEventListener(...): Apply addEventListener for all Elements[] based on ignores and includes

Example

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •