Giter Site home page Giter Site logo

repeatable-fields's Introduction

Repeatable Fields

Plugin's Homepage with Demo

Description

Repeatable Fields is a jQuery plugin which let's you create a set of fields that can be made to repeat. You can do the following to a field that is repeatable:

  • Add new instance
  • Remove existing instance
  • Reposition an instance

The functionality that is provided by this plugin can also be referred to as:

  • Dynamic Fields Plugin
  • Dynamic Rows plugin
  • Add Remove Rows Plugin

Requirements

This plugin requires jQuery and jQuery UI Sortable.

Example

HTML

<div class="repeat">
	<table class="wrapper" width="100%">
		<thead>
			<tr>
				<td width="10%" colspan="4"><span class="add">Add</span></td>
			</tr>
		</thead>
		<tbody class="container">
		<tr class="template row">
			<td width="10%"><span class="move">Move</span></td>
	
			<td width="10%">An Input Field</td>
			
			<td width="70%">
				<input type="text" name="an-input-field[{{row-count-placeholder}}]" />
			</td>
			
			<td width="10%"><span class="remove">Remove</span></td>
		</tr>
		</tbody>
	</table>
</div>

JavaScript

jQuery(function() {
	jQuery('.repeat').each(function() {
		jQuery(this).repeatable_fields();
	});
});

Options

wrapper: '.wrapper',
container: '.container',
row: '.row',
add: '.add',
remove: '.remove',
move: '.move',
template: '.template',
is_sortable: true,
before_add: null,
after_add: after_add,
before_remove: null,
after_remove: null,
sortable_options: null,
row_count_placeholder: '{{row-count-placeholder}}',
wrapper
Specifies an element that acts as a wrapper.
container
Specifies an element within the wrapper which acts as a container.
row
Specifies an element within the container that acts as a row holder. The row is what is repeated.
add
Specifies an element within the wrapper which let's you add more more
remove
Specifies an element within the row which let's you remove the current row
move
Specifies an element within the row which let's you reposition the current row.
template
Specifies an element within the container which acts as a row template.
is_sortable
Specifies whether rows can be sorted
before_add
Specifies a function to run before a row is added
after_add
Specifies a function to run after a row is added
before_remove
Specifies a function to run before a row is removed
after_remove
Specifies a function to run after a row is removed
sortable_options
Specifies an object that can contain Options, Methods and Events which are passed to jQuery UI Sortable
row_count_placeholder
Specifies the row count placeholder to be used

repeatable-fields's People

Contributors

naifamoodi avatar vpratfr avatar

Watchers

James Cloos avatar ]\[  ][  ']['  ][  ]\[ avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.