forked from nilbus/unserialize-to-form
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
49 lines (38 loc) · 1.73 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
jQuery Unserialize (to) Form
----------------------------
Version 1.0.5
Simple jQuery plugin to unserialize data back into forms.
Usage:
var s = $("form").serialize(); // save form settings.
$("form").unserializeForm(s); // restore form settings
The serialized form data could be saved in a session, perhaps in HTML5 sessionStorage.
Note that saving the serialized data to a cookie is troublesome as not all browsers
implement the same cookie string lengths, so sessionStorage or a SQL db is recommended.
Alternate Usage:
var cb = function(element, value) { return true; // or false }
var s = $("form").serialize();
$("form").unserializeForm(s, {
'callback' : cb,
'override-values' : false
});
callback (optional):
The above callback is given the element and value, allowing you to build
dynamic forms via callback. If you return false, unserializeForm will
try to find and set the DOM element, otherwise, (on true) it assumes you've
handled that attribute and moves onto the next.
override-values (optional, default is false):
Controls whether elements already set (e.g. an input tag with a non-zero length value)
will be touched by the unserializer. Does not apply to radio fields or checkboxes.
If you have a use case for radio fields or checkboxes, please file an issue at
https://github.com/cthielen/unserialize-to-form/issues/ . Also note this option
does not apply to a callback, i.e. a callback would still have the opportunity
to override a value even if this option is set to false. It is up to you as
the callback author to enforce the behavior you wish.
Known issues:
* None.
Special thanks / Contributors:
Anton
Thiago Macedo
genellern
Edward Anderson
hoka