Good time% username%!
I want to submit to the public one interesting plugin to control the state of the form.
What is a “form state”? This is a cast of the values that were set in the form at the time of its initialization. There is nothing superfluous in the plugin, no “preference and harlots”, only what it was designed for, namely control over changing values in the form. What is it for? Well, there are all sorts of situations, for example, for logging changes that have been made to the data. You can try to control the event leaving the page, suddenly, the user has entered something, and forgot to save?
Who
cares , you can play on
jsfiddle .
')
By itself, the plugin is extremely simple. Initialization:
$(document).ready(function() { $('form').state_form(); });
or extended option:
$(document).ready(function() { $('form').state_form({
Check for status changes:
$('form').state_form('is_changed');
Get modified fields:
$('form').state_form('get_changes');
A handler is attached to the form submit event, which before it collects all the changes, encodes them in json, creates a field in the form where it inserts the resulting string, and the changes are sent to the server. This feature can be disabled.
UPD: updated the plugin to 0.0.3, where he added methods of working with the state history. Thanks to
RubaXa for suggestions and criticism!
Source code
github.com/Slavenin/state_formI would be happy for comments and suggestions!
Thank you for attention!