|File Size:||17.4 KB|
|Official Website:||Go to website|
Squirrel.js is a simple yet useful jQuery plugin that automatically and temporarily stores the information from the form as you type in fields or change values, until the form is submitted.
The plugin uses HTML5 sessionStorage for the current form state in case you refresh the browser or navigate away and return.
You might also like:
- Automatically Persist Text Field Values Locally - Garlic
- jQuery Plugin to Save Form Fields Values To localStorage - phoenix
- jQuery Plugin to Restore User Previously Entered Values - Remember State
- jQuery Plugin To Autosave Form Content - autoSave
- jQuery Plugin For Auto Saving Form Values
How to use it:
1. Load the jQuery library and squirrel.js script at the end of the Html page.
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> <script src="jquery.squirrel.min.js"></script>
2. Enable the plugin on an Html form by just adding a CSS class name of 'squirrel' to it. The plugin will do the rest.
<form action="/" method="post" class="squirrel"> </form>
3. Some default options for Squirrel.js.
clear_on_submit: true, storage_method: 'session', storage_key: 'squirrel', storage_key_prefix: ''
- Using jQuery's trim and tidied code
- Added storage_key_prefix prefix and added sanitize option strings
- Onload function in correct scope
- Trim whitespace whilst checking isString
- Check if the storage_method is a string
- Using on() instead of the event aliases
- Removed converting action to lowercase
- Moved section that checks if the storage property is valid
- Reduced code by caching the storage property
- Added $.each() loop back into select logic to allow multiple options being selected.
- Added support for localStorage as a configuration option.
- Add support for all HTML5 input types - color, date, datetime, datetime-local, month, week, time, range, search, tel, and URL.
- Configured to also include input type='email' fields (added a test field to index file and styled those input types as well for the demo).
- Added action parameter in front of the options parameter. This will change things a little going forward, but most default configurations will still work.
- Adding comments, moving stash and unstash functions out of the loop so they're only defined once.