0.5.0 • Published 4 years ago

@robmarr/intercept-form-submits v0.5.0

Weekly downloads
6
License
ISC
Repository
github
Last release
4 years ago

Intercept Form Submits

This module is mainly to intercept applicable form submits for a single-page app router. The options are geared toward intercepting internal links that should change the page state in some way.

Install

npm i intercept-form-submits

Usage

var interceptSubmits = require('intercept-form-submits');

interceptSubmits(function(e, el) {
  // Change the page state here
  // `e` is the event object
  // `el` is the submitted form, which might be different from `e.target`
});

A more advanced usage is to pass options and an optional element:

interceptSubmits(document.querySelector('.my-el'), {
  //
  // Leave all these as defaults:
  //
  // dialog: true
  // get: true
  // post: true
  // mailTo: true
  // sameOrigin: true
  // target: true
  // Intercept all submits, even ones that are not same origin
  sameOrigin: false
}, function(e, el) {
  // Change the page state here
});

Thanks Wes Todd for Intercept Link Clicks on which this module is heavily based.

0.5.0

4 years ago

0.3.0

4 years ago

0.4.0

4 years ago

0.2.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago