This is a module to simply add a input with multiple element to your site.
- JQuery
Load the required files. Inside the page's head tag include the input-multi-element's CSS file.
<link rel="stylesheet" href="/your-path/input-multi-element.css">
And in the page's footer, include the required javascript files.
<script src="/your-path/input-multi-element.js"></script>
For initialize the input-multi-element, insert this example snippet and update this with your parameters. Exemple:
$(document).ready(function() {
InputMultiElement().init(
"#input-multi-element",
{
maxElement: 50
}
);
});
maxElement: [number]
- inputMultiElement().init
- inputMultiElement().setElement
- inputMultiElement().setElements
- inputMultiElement().getElements
- inputMultiElement().getElementsDOM
- inputMultiElement().getElementById
- inputMultiElement().getElementDOMById
- inputMultiElement().getNbElements
- inputMultiElement().deleteLastElement
- inputMultiElement().deleteElementById
- inputMultiElement().deleteElementsByValue
- inputMultiElement().updateElementsById
- inputMultiElement().updateElementsByValue
- inputMultiElement().hasElement
- inputMultiElement().nbElementByValue
- inputMultiElement().activateTextZone
- inputMultiElement().clearTextZone
/**
* Used to create the input mutli element
*
* @param {string} _elem Class or id of the input mutli element
* @param {Array} _opts List of options
*/
inputMultiElement.init(_elem, _opts)
inputMultiElement().setElement
/**
* Used to set a element with a index or not
*
* @param {string} _text Text of the element
* @param {number} _index Index of the element
*/
inputMultiElement.setElement(_text, _index)
inputMultiElement().setElements
/**
* Used to set a array of elements with a index or not
*
* @param {Array} _texts Array of the string elements
* @param {number} _index Index of the first element of the array
*/
inputMultiElement.setElements(_texts, _index)
inputMultiElement().getElements
/**
* Used to get an array of string of elements
*
* @returns {Array} Returns an array of elements
*/
inputMultiElement.getElements()
inputMultiElement().getElementsDOM
/**
* Used to get an array of DOM elements
*
* @returns {Array} Returns an array of DOM elements
*/
inputMultiElement.getElementsDOM()
inputMultiElement().getElementById
/**
* Used to get an element with an index
*
* @param {number} _index Index of the element
* @returns {Array} Returns an element
*/
inputMultiElement.getElementById(_id)
inputMultiElement().getElementDOMById
/**
* Used to get an DOM element with an index
*
* @param {number} _index Index of the element
* @returns {Array} Returns a DOM element
*/
inputMultiElement.getElementDOMById(_id)
inputMultiElement().getNbElements
/**
* Used to get a number of the elements
*
* @returns {number} Returns number of elements
*/
inputMultiElement.getNbElements()
inputMultiElement().deleteLastElement
/**
* Used to delete the last element
*/
inputMultiElement.deleteLastElement()
inputMultiElement().deleteElementById
/**
* Used to delete an element with a index
*
* @param {number} _index Index of the element
*/
inputMultiElement.deleteElementById(_id)
inputMultiElement().deleteElementsByValue
/**
* Used to delete an elements with a value
*
* @param {string} _values Value of the elements
*/
inputMultiElement.deleteElementsByValue(_value)
inputMultiElement().updateElementsById
/**
* Used to update an elements with an index
*
* @param {string} _value Value of the elements
* @param {number} _index Index of the elements
*/
inputMultiElement.updateElementsById(_value, _id)
inputMultiElement().updateElementsByValue
/**
* Used to update an elements with a value
*
* @param {string} _newValue New value of the elements
* @param {string} _lastValue Last value of the elements
*/
inputMultiElement.updateElementsByValue(_newValue, _lastValue)
inputMultiElement().hasElement
/**
* Used to know if an element exist
*
* @param {string} _value Value of the elements
* @returns {boolean} Return true if the element exist if not false
*/
inputMultiElement.hasElement(_value)
inputMultiElement().nbElementByValue
/**
* Used to get a number of the elements with a value
*
* @param {string} _value Value of the elements
* @returns {number} Returns number of elements by value
*/
inputMultiElement.nbElementByValue(_value)
inputMultiElement().activateTextZone
/**
* Used to activate the text zone
*
* @param {boolean} _bool True to activate / False to desactivate
*/
inputMultiElement.activateTextZone(_bool)
inputMultiElement().clearTextZone
/**
* Used to clear the text zone
*/
inputMultiElement.clearTextZone()