开发者社区> 镜像站> NPM> remoteform
remoteform
Ajaxify forms easily
Last updated a year ago by rexblack .
MIT · Original npm · Tarball · package.json
$ cnpm install remoteform 
SYNC missed versions from official npm registry.

remoteform

Ajaxify forms easily

Install

First of all install nodejs if you haven't already.

In your project directory, hit the following command order to install remoteform:

npm install remoteform --save

remoteform relies on fetch for making requests, hence you may need to install a polyfill in addition.

Usage

Create your html form

<div id="test" class="remoteform">
  <form action="/submit.html" method="POST">
    <div class="form-group">
      <input class="form-control" name="test" value=""/>
    </div>
    <button class="btn btn-primary" type="submit">Submit</button>
  </form>
</div>

Import remoteform to your bundle and initialize with the specified selector:

const remoteform = require('remoteform');

remoteform('#test');

If you control all forms on your site, you may want to ajaxify all forms globally by omitting the selector or passing in form.

Customizing response selector

By default, remoteform generates a unique selector for the given element against which it matches the response. You can customize the responseSelector by specifying the corresponding option as follows.

const remoteform = require('remoteform');

remoteform('#test', {
  responseSelector: '.my-response-selector'
});

Options

Name Type Description
request Object Options passed to fetch
responseSelector String Customize the remote content selector

Current Tags

  • 0.0.6                                ...           latest (a year ago)

5 Versions

  • 0.0.6                                ...           a year ago
  • 0.0.5                                ...           a year ago
  • 0.0.4                                ...           2 years ago
  • 0.0.3                                ...           3 years ago
  • 0.0.2                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (23)
Dependents (0)
None