Element to be used as the button for adding elements, in addition the plus and minus icons. None by default.
Element to be used as the button for removing elements, in addition the plus and minus icon. None by default.
This option lets you hide the add and remove buttons, in case the user should not be able to add or remove elements dynamically. The allowed values for this option are:
false
: All buttons are shown and can be used (the default)true
: Both the add and the remove buttons are hidden.[]
(no buttons are hidden), ["add"]
,
["delete"]
or ["add", "delete"]
.The maximum number of repetitions. Default: 10.
The minimum number of repetitions. Default: 1.
If given, the value of this element is used as the number of dynamically created items. Whenever the given element's value changes, dynamically created items are added or removed to reflect the new value.
For example, consider a dynamic container with the details for a child. If you set the trigger to an input
element number of children
, there are always as many copies of the child details container as the number of
children entered.
Optional callback function called after an element was added.
Event which triggered the addition of a new item.
The element that was added.
Optional callback function called after an element was removed.
Note that this callback lets you to access the element that was removed. As it is already detached from the DOM, only certain properties such as its value and its children can still be accessed. Certain actions such as checking the element's visiblity are not available anymore.
Event which triggered the removal.
The element that was removed.
Optional callback function called before an element is about to be added.
Note that this callback lets you to access the element before it was added. As it is not yet detached to the DOM, only certain properties such as its value and its children can be accessed. Certain actions such as checking the element's visiblity are not yet available.
Event which triggered the addition of a new item.
The element that is about to be added.
Iff false
, the element will not be added.
Optional callback function called before an element is about to be removed.
Event which triggered the removal.
The item that is about to be removed.
Iff false
, the element will not be deleted.
A function that is called every time an item is added or removed.
The current count of dynamically created items.
The item that was added or removed.
true
iff the item was added, false
iff it was removed.
A form element can be made repeatable by calling
$(formElement).dynamic()
. This is the configuration object that may be passed optionally to configure how many repetitions are allowed and much more.$("[name='fsAddresse']").dynamic({ minSize: 1, // At least 1 address maxSize: 6 // At most 6 adresses });