jquery.formLocalStorage is a jquery plug-in that implements universal form temporary storage function
Principle:
Monitor changes in form fields, use localStorage in HTML5 WebStorage to store the values of these changed form fields, and load the stored values back into the form fields when the form is reloaded, thereby implementing the temporary storage function.
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(); to get it done. There is no need to write a lot of server-side logic.
3. Rich configuration items and default values. Through the configuration items, you can customize the style of the temporary content, the callback events after the temporary storage is loaded, stored and deleted, as well as the temporary storage naming rules. You can also use Default values thereby reducing excessive configuration work.
Usage:
1. Use default configuration:
$("#your_form_id").formLocalStorage();
2. Use custom configuration:
$("#your_form_id").formLocalStorage({ storage_name_perfix : 'your_storage_name_perfix', //自定义暂存存储的命名前缀 storage_events : 'click' //自定义暂存触发事件 });
Known issues:
1. Some contents dynamically written into form items cannot be monitored and cannot be temporarily saved.
2. The default storage_name_perfix is this.context.URL + form_selector + "@". If this.context.URL changes after submission, the temporary storage will not 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