Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kflorence/jquery-deserialize
Decodes serialized form data and populates a form with that data.
https://github.com/kflorence/jquery-deserialize
Last synced: 7 days ago
JSON representation
Decodes serialized form data and populates a form with that data.
- Host: GitHub
- URL: https://github.com/kflorence/jquery-deserialize
- Owner: kflorence
- License: gpl-2.0
- Created: 2011-04-20T20:14:33.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2021-08-27T04:06:15.000Z (about 3 years ago)
- Last Synced: 2024-09-22T23:03:09.128Z (about 2 months ago)
- Language: JavaScript
- Homepage: http://kflorence.github.com/jquery-deserialize/
- Size: 154 KB
- Stars: 187
- Watchers: 10
- Forks: 59
- Open Issues: 5
-
Metadata Files:
- Readme: readme.md
- License: license-gpl
Awesome Lists containing this project
README
# jQuery.deserialize
$("form").deserialize(data[, options]);
Decodes serialized form data and populates the form with that data. This method works upon text strings in standard URL-encoded notation, arrays containing objects of name/value pairs or objects containing name/value pairs. Thus, the plugin is compatibile with the data collected using the following methods:
* [jQuery.serialize()](http://api.jquery.com/serialize)
* [jQuery.serializeArray()](http://api.jquery.com/serializeArray)
* [jQuery.serializeObject()](http://benalman.com/projects/jquery-misc-plugins/#serializeobject) (unofficial)## Install
Download as [NPM](http://npmjs.org) module:
npm install jquery-deserialize
Download as [Bower](http://bower.io) component:
bower install jquery-deserialize
## Example
Populate a form on page load using query string parameters:
```javascript
jQuery(function( $ ) {
$( 'form' ).deserialize( location.search.substr( 1 ) );
});
```## Arguments
The plugin accepts two arguments: _data_ and _options_, the latter being optional. Passing the _complete()_ function as the second argument to this plugin is also supported.
* **data** _String_, _Array_, _Object_ A serialized (and/or encoded) String, an Array of objects containing name/value pairs, or an object of name/value pairs.
* **options** _Object_ An object of key/value pairs that configure the plugin.
* **change** _Function_ Called for every changed input value.
* **complete** _Function_ Called when all of the inputs have been updated.
* **filter** _String|Function|Element|jQuery_ A custom filter to identify inputs to deserialize. By default, all inputs that are not disabled will be deserialized (this matches the behavior of serialization).## Requirements
jQuery.deserialize requires:
* jQuery version 1.4.3+ ([A patch is available](https://github.com/kflorence/misc-js/raw/master/jquery/patches/jquery.type-patch.js) for versions 1.2+).
## License
Copyright (c) Kyle Florence
jQuery.deserialize is dual licensed under MIT and GPLv2 licenses.