DataSaver

jQuery plugin for save your data.


About

The jQuery plugin allows you to save data from form fields in the web storage.

This saves users from a situation when they lost all data entered into the form. This can happen due to a crash browser, disconnection, reload the page, etc.


Browser Support:

Plugin is supported in Internet Explorer 8+, Firefox 3.5+, Opera 10.5+, Chrome 4.0+, and Safari 4.0+.


Usage

DataSaver plugin uses the jQuery JavaScript library, only. So, include just these two javascript files in your header.

<script src="js/jquery.js"></script>
<script src="js/jquery.DataSaver.js"></script>
		

Select elements whose data you want to save.

<input type="text" id="field" class="saveme" /> 
<textarea class="saveme"> </textarea>
		

After it, call the jQuery DataSaver plugin.

$('.saveme').DataSaver();	
		

Options:

You can pass an options object in plugin init method.

$('.saveme').DataSaver({
    timeout: 1000, 
    events: "change keyup",
    keyUrlAttrs: ["host", "pathname", "search"],
    keyExtra: function() { 
        return $('#linkedfield').val(); 
    }
});
		


Methods:

You can call some methods. Just pass their name.

$('.saveme').DataSaver('remove');
		


Events:

You can listen DataSaver events.

You can also get localStorage key (DataSaver_key) and value:

$(document).on("DataSaver_save DataSaver_load DataSaver_remove", function(e) {
	console.log(e.type);
	console.log(e.target.DataSaver_key + " : " + localStorage[e.target.DataSaver_key]);
	console.log("");
});
		


Example:

Fill and reload the page.

Input:

Radio: One Two Three

Select:

Multiple select:

Checkbox: Check Check Check

Textarea:



ABSENT, 2014