Today I want to introduce a jQuery plug-in: jquery. formLocalStorage. js. With this plug-in, we can easily implement the form temporary storage function jquery. formLocalStorage is a jquery plug-in that implements the general form temporary storage function
Principle:
Monitors changes in form fields, uses localStorage in HTML5 WebStorage to store the values of these changed form fields, and loads the stored values back to the form field when loading the form, this allows for temporary storage.
Features:
1. Do not use server-side storage to save server resources.
2. The code is concise. If you use the default configuration, you only need a short piece of code $ ("# your_form_id"). formLocalStorage ();. You do not need to write a large volume of server logic.
3. rich configuration items and default values. You can use the configuration items to customize the style of the temporary content, the callback events after the temporary content is loaded, stored, and deleted, and the temporary storage naming rules, you can also use the default value to reduce excessive configuration work.
Usage:
1. Use the Default Configuration:
$("#your_form_id").formLocalStorage();
2. Use custom Configuration:
$ ("# Your_form_id "). formLocalStorage ({storage_name_perfix: 'Your _ storage_name_perfix', // custom name prefix storage_events: 'click' // custom temporary storage trigger event });
Known issues:
1. The content of some dynamically written form items cannot be monitored or saved temporarily.
2. the default storage_name_perfix is this. context. URL + form_selector + "@", if this. context. if the URL changes, the temporary storage cannot be located. It is best to use another unique value as the default storage_name_perfix.
Plug-in download http://xiazai.jb51.net/201602/yuanma/jquery.formLocalStorage (jb51.net).zip