formie
** CommonJS/Browserified ajax form submission **
Formie submits form data via AJAX. Formie supports JSONP, GET, POST, DELETE and multipart/form-data file Uploads without the baggage of a full framework.
Example
Check out example/index.html
, the example javascript for the example page is resources/js/example_src.js
Installation
$ npm install formie
Formie is a browserified/commonjs javascript module.
Usage
JavaScript
var Formie = myFormie; //initialize nav component after the dom has loadedwindow;
HTML
Your Page Field 1 Field 2
OPTIONS
defaultOptions = ajaxsubmitfileuploadclassname: 'formie-file' //file input class to readAsDataURL ajaxformselector: '#formie' //formie form selector ajaxsubmitform: null jsonp: false //retrieves data via JSONP, form data must contain a 'callback' parameter autosubmitselectors: '.autoFormSubmit' autosubmitelements: preventsubmitselectors: '.noFormSubmit' preventsubmitelements: headers: {} // custom headers to submit queryparameters: {} // programmitcally add more get data postdata: {} // programmitcally add more post data beforesubmitcallback: null // callback(event,formelement) errorcallback: null // callback(error,response) successcallback: null // callback(response);
API
//submit formie via ajaxmyFormie; //eventsmyFormie; // callback(formelement)myFormie; // callback(eventTarget)myFormie; // callback()myFormie; // callback(formieData)
Development
Make sure you have grunt installed
$ npm install -g grunt-cli
Then run grunt watch
$ grunt watch #uses grunt-connect on port 8181
For generating documentation
$ grunt doc
$ jsdoc2md lib/**/*.js index.js > doc/api.md
Notes
- The Formie uses Node's event Emitter for event handling.
- In order to test post submission, grunt connect is used on port 8181