An open API service indexing awesome lists of open source software.

https://github.com/sutara79/jquery.add-input-area

jQuery plug-in. You can add or delete the list of input area.
https://github.com/sutara79/jquery.add-input-area

html-form jquery-plugin

Last synced: 10 months ago
JSON representation

jQuery plug-in. You can add or delete the list of input area.

Awesome Lists containing this project

README

          

# jquery.add-input-area

[![npm version](https://img.shields.io/npm/v/jquery.add-input-area.svg)](https://www.npmjs.com/package/jquery.add-input-area)
[![Build Status](https://travis-ci.org/sutara79/jquery.add-input-area.svg?branch=master)](https://travis-ci.org/sutara79/jquery.add-input-area)

jQuery plugin to add or delete form fields.

![Sample image](demo/image.png)

## Demo
https://sutara79.github.io/jquery.add-input-area/

## Install
- [GitHub](https://github.com/sutara79/jquery.add-input-area): Clone or download.
- [npm](https://www.npmjs.com/package/jquery.add-input-area): `npm i jquery.add-input-area`
- CDN [(jsDelivr)](https://www.jsdelivr.com/):
- [jquery.add-input-area.min.js (v4.11.0)](https://cdn.jsdelivr.net/npm/jquery.add-input-area@4.11.0/dist/jquery.add-input-area.min.js)

## Usage

###### HTML
```html




  1. Delete

```

###### JavaScript
```javascript
$('#list').addInputArea();
```

## Naming convention
- CSS class for the wrapper of form fields: `.(id)_var`
- CSS class for del-button: `.(id)_del`
- CSS class for add-button: `.(id)_add`

You can change these rules above by options. (`area_var`, `btn_add`, `btn_del`)

- Form field: `(a text)_0`

If you follow this rule, "name", "id" and "for" attribute are numbered automatically.

```html
(default)

(add)

```

You can use original naming convention by setting custom data attribute, "data-name-format" or "data-id-format".

``` html
(default)

(add)

```

```html
(default)

(add)

```

- See [How to use on CakePHP (jquery.add-input-area v4.7.1, CakePHP v2.3.8)](http://code.runnable.com/U7vCAlCwvQZzFZBO/how-to-use-jquery-add-input-area-on-cakephp)

## Options
|Name |Type |Default |Description |
|-------------------------------------------------------------------------|--------|-----------|----------------------------------------------|
|[area_var](https://sutara79.github.io/jquery.add-input-area/#index_02) |string |'.(id)_var'|CSS class for the wrapper of form fields. |
|[btn_add](https://sutara79.github.io/jquery.add-input-area/#index_02) |string |'.(id)_add'|CSS class for add button. |
|[btn_del](https://sutara79.github.io/jquery.add-input-area/#index_02) |string |'.(id)_del'|CSS class for delete button. |
|[area\_del](https://sutara79.github.io/jquery.add-input-area/#index_04) |string |(btn_del) |CSS class for wrapper of delete button. |
|[after_add](https://sutara79.github.io/jquery.add-input-area/#index_10) |function|null |A callback function to be called after adding.|
|[clone_event](https://sutara79.github.io/jquery.add-input-area/#index_11)|boolean |true |If event will be copied or not. |
|[maximum](https://sutara79.github.io/jquery.add-input-area/#index_05) |number |0 |Max number of wrapper of form fields. "0" means unlimited.|
|[dont_clone](https://sutara79.github.io/jquery.add-input-area/#index_12) |string |null |CSS selector to avoid cloning.|
|[validate](https://sutara79.github.io/jquery.add-input-area/#index_13) |function |null |Validation before adding. Should return boolean. If false, adding stops.|

## License
[MIT](https://www.opensource.org/licenses/mit-license.php)

## Author
[Yuusaku Miyazaki](http://d.hatena.ne.jp/sutara_lumpur/20120509/1336556562)
( )