https://github.com/benignware/remoteform
Ajaxify forms easily
https://github.com/benignware/remoteform
ajax forms
Last synced: 7 months ago
JSON representation
Ajaxify forms easily
- Host: GitHub
- URL: https://github.com/benignware/remoteform
- Owner: benignware
- Created: 2018-01-23T20:00:36.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T21:42:53.000Z (about 3 years ago)
- Last Synced: 2025-08-10T01:32:36.225Z (8 months ago)
- Topics: ajax, forms
- Language: JavaScript
- Homepage:
- Size: 1.65 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# remoteform
Ajaxify forms easily
## Install
First of all install [nodejs](https://nodejs.org]) if you haven't already.
In your project directory, hit the following command order to install `remoteform`:
```cli
npm install remoteform --save
```
`remoteform` relies on `fetch` for making requests, hence you may need to install a [polyfill](https://www.npmjs.com/package/isomorphic-fetch) in addition.
## Usage
Create your html form
```html
Submit
```
Import `remoteform` to your bundle and initialize with the specified selector:
```js
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.
```js
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 |