Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/andrienko/preservejs

A lame form value preservation script
https://github.com/andrienko/preservejs

Last synced: 7 days ago
JSON representation

A lame form value preservation script

Awesome Lists containing this project

README

        

PreserveJS
===
Hello. This one is a tiny library that helps you to save entered values of HTML elements.
It is actually pretty lame.

This helps to not lose form values on tab close/page reload. If you need something super-stable -- write your own.

Usage
---
All you have to do is add the script in your html file:



And then add the "preserve" property to any html element:



This will save element value every time it changes, in a localstorage.

Preservation ID
---

Values are saved in an identifier which, if no value for "preserve" attribute is set, is generated, url- and
elementID-dependant. You can alter this by specifying the value for preserve attribute

Preservation ID generation
---
By default the values are saved by a key formed from current url + hash symbol + id or name of element. (Name is used
if id is empty). Say, for this:

The value, on http://localhost/preserve will be saved in a key called `localhost/preserve#checkit`. This means that, say,
on http://localhost/preserve?mode=gallery page it will not be preserved, even if input has same id.

Future Plans
---

- Support for select multiple

Warning
---
LocalStorage is limited to 5MB. So maybe consider not using this for large input fields etc.