1.0.0 • Published 7 years ago

form-data-object v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

Form Data Object badge-size npm version

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:

<script src="dist/form-data-object.min.js"></script>
npm install --save form-data-object

Usage

  1. Import the plugin

        import allFormData from 'form-data-object';
  2. Instantiate the class and pass it your wrapper elements in an array. E.g.

        let myFormData = new allFormData([document.getElementById('my-form'), document.getElementById('my-other-div')]);

    or, if you just want a single wrapper

        let myFormData = new allFormData([document.getElementById('my-form')]);

    maybe you don't want the data to be encoded

        let myFormData = new allFormData([document.getElementById('my-form')], false);

    maybe you want the data returned as a generic javascript object (instead of FormData)

        let myFormData = new allFormData([document.getElementById('my-form')], true, true);
  3. Call method to return the single FormData object. E.g.

        myFormData.getFormData()

Parameters

(wrappers, encode, jsObject)

MIT © Chris Boakes

1.0.0

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago