Form Data Object
Creates a single FormData object (or generic javascript object - optional) from multiple wrapper elements and encodes the data (optional) with no framework dependencies.
- Fast and lightweight
- Doesn't rely on a form tag (you can use whichever wrapper tag you like)
- You can use multiple wrappers
- Optionally encodes the data
- No framework dependencies
Installation
However you like:
npm install --save form-data-object
Usage
-
Import the plugin
; -
Instantiate the class and pass it your wrapper elements in an array. E.g.
let myFormData = document document;or, if you just want a single wrapper
let myFormData = document;maybe you don't want the data to be encoded
let myFormData = document false;maybe you want the data returned as a generic javascript object (instead of FormData)
let myFormData = document true true; -
Call method to return the single FormData object. E.g.
myFormData
Parameters
(wrappers, encode, jsObject)
parameter | description |
---|---|
wrapper(s) |
Type: array Default: null Array of DOM wrappers. If using a single wrapper, just place it in an array. More info in the Usage section |
encode |
Type: boolean Default: true Do you want the data to use Javascript's encodeURIComponent()
|
jsObject |
Type: boolean Default: false Do you want to return a generic Javascript object instead of a FormData() object?
|
MIT © Chris Boakes