UNPKG

dom-form-submit

Version:
56 lines (39 loc) 1.21 kB
# DOM-Form-Submit Utility build or use form and submit using provided data. This library will intelligently reuse the same form and perform minimal manipulations for optimum performance. [![Build Status](https://travis-ci.org/hasnat/dom-form-submit.svg)](https://travis-ci.org/hasnat/dom-form-submit) [![NPM](https://nodei.co/npm/dom-form-submit.png)](https://nodei.co/npm/dom-form-submit/) # Installation #### Npm ```console npm install dom-form-submit ``` # Example ```javascript var submit = require('dom-form-submit'); // Submit form with data (create or use existing form) with callback to run after submit submit( {a: 'b', c: 'd'}, {id: 'my-form-id', name: 'my-form-name'}, function(submittedForm) {} // callback with form element ); // Submit an existing form. submit({a: 'b', c: 'd'}, { method: 'POST', form: document.getElementById('my-form') }); // Basically empty form submit submit(); ``` # API Options / Defaults. ```javascript { method: 'GET', enctype: 'application/x-www-form-urlencoded', target: '_self' } ``` Please feel free to create a PR! ### Thanks to https://github.com/gillstrom/submitform https://github.com/DylanPiercey/submit-form