Forked from http://github.com/jakubpawlowicz/jquery.deserialize
This is a very simple jQuery plugin providing 'deserialize' functionality to a form elements. In contrary to some other plugins available it doesn't reinvent the wheel (by utilizing native browser methods) and actually works.
$("#form-id").deserialize(string, options)
Allows You to limit set of form fields by either black-listing (except) or white-listing (only):
$("#form-id").deserialize(string, {
except : ['generated_token', 'another_field']
})
These options are exclusive: You cannot pass both in the same time.
Allows You to pass function, called when certain fields are being populated:
$("#form-id").deserialize(string,
callback_on : ['one', 'two', 'three'],
callback : function(name, value){
# NOTE: works only in Firefox with Firebug installed
console.log(name + " has been populated by " + value)
}
})
You can leave callback_on
black to call given function on every populated field.
Allows You to change default attribute (name
), which will be used to match fields in this way: [name='value']
.
See demo.html
for some examples.
- allow to pass JSON objects as data for deserialization
except
,only
andcallback_on
options should accept regular expressions- add more examples to reflect all possible options
- add possibility to chage the way the fields are matched