Skip to content

Unserialize data back into DOM forms

License

Unknown, Unknown licenses found

Licenses found

Unknown
LICENSE.GPL2
Unknown
LICENSE.MIT
Notifications You must be signed in to change notification settings

victorgdb/unserialize-to-form

 
 

Repository files navigation

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

About

Unserialize data back into DOM forms

Resources

License

Unknown, Unknown licenses found

Licenses found

Unknown
LICENSE.GPL2
Unknown
LICENSE.MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published