jQuery-form-serializer
Serialize forms to JSON objects in a friendly way.
Example
First name Enter your first name. Last name Enter your first name. Age How old are you? If you provide 0, the age field will be deleted. Developer How old are you? If you provide 0, the age field will be deleted. Bio I'm a web developer and pianist from Romania. Readonly I'm readonly content and my value is taken with data-value="html". Submit
Documentation
serializer()
Create the form serializer.
Return
- jQuery The selected elements.
Events
serializer:data
⬅️
This event is used to listen for form data.
;
serializer:submit
➡️
When serializer:submit
is triggered, then the form is serializer and the data comes
in the serializer:data
callback.
;
serializer:fill
➡️
By triggering serializer:fill
the form is filled with data that is sent.
var formData = name: first: "Alice" ;;
Attributes
Value | Description | Default value | Required | Example |
---|---|---|---|---|
data-field |
Name of the key from object. |
No default value. | Yes | data-field="author" |
data-value |
It's the name of the function how the value will be taken. | val |
No (will take the default value) | data-value="text" |
data-params |
Params of jQuery function set as data-value . |
No default value | Not required. | data-params="checked" |
data-convert-to |
The data type. Can be one of the following values:
|
No default value | Not required. | data-convert-to="boolean" |
data-delete-if |
If provided, the field will be deleted if it's equal with the attribute value. | No default value | Not required. | data-delete-if="" |
How to contribute
- File an issue in the repository, using the bug tracker, describing the contribution you'd like to make. This will help us to get you started on the right foot.
- Fork the project in your account and create a new branch:
your-great-feature
. - Commit your changes in that branch.
- Open a pull request, and reference the initial issue in the pull request message.
License
See the LICENSE file.