Name | Description |
---|---|
public constructor()
|
Create a new instance of the Tagify class. See tagify documentation for options not listed here. Parameters:
|
public addTags()
|
Add one or more tags.
Parameters:
Return:
|
public removeAllTags()
|
Removes all tags and resets the original input tag's value property. |
public setReadonly()
|
Sets the read-only state of the Tagify instance.
Parameters:
|
public setDisabled()
|
Sets the disabled state of the Tagify instance.
Parameters:
|
public onAddTag()
|
Sets the callback function to be called when a tag is added.
Parameters:
Return:
|
public onRemoveTag()
|
Sets the callback function to be called when a tag is removed.
Parameters:
Return:
|
public onChangeTag()
|
Sets the callback function to be called when the tag is modified.
Parameters:
Return:
|
public dispose()
|
Reverts the input element back as it was before Tagify was applied. |
<!--begin::Tagify-->
<input id="basicTagify" class="form-control form-control-solid" value="tag1" />
<!--end::Tagify-->
import {components} from 'metronic-extension';
// Initialize Tagify.
const basicTagify = new components.Tagify(document.getElementById('basicTagify'));
// Set callback functions for various operations.
basicTagify
.onAddTag(event => {
// Tag added.
console.log('Tag added');
})
.onRemoveTag(event => {
// Tag removed.
console.log('Tag has been deleted');
})
.onChangeTag(event => {
// Tag was changed.
console.log('Tag has been changed');
});
readonly
option is set to true
, the Tagify will be read-only.
<input id="readonlyTagify" class="form-control form-control-solid" value="tag1" />
import {components} from 'metronic-extension';
// Read-only.
new components.Tagify(document.getElementById('readonlyTagify'), {
readonly: true,
});
<input id="inlineSuggestionsTagify" class="form-control form-control-solid" value="tag1" />
import {components} from 'metronic-extension';
// Inline Suggestions.
new components.Tagify(document.getElementById('inlineSuggestionsTagify'), {
whitelist: ['tag1', 'tag2', 'tag3'],
dropdown: {
maxItems: 20,
classname: 'tagify__inline__suggestions',
}
});
<input id="listSuggestionsTagify" class="form-control form-control-solid" value="tag1" />
import {components} from 'metronic-extension';
// List Suggestions.
new components.Tagify(document.getElementById('listSuggestionsTagify'), {
whitelist: ['tag1', 'tag2', 'tag3'],
dropdown: {
maxItems: 20,
},
});
<Select>
element, but allows free text as value.
<input id="singleValueSelectTagify" class="form-control form-control-solid" value="tag1">
// Single-Value Select.
new components.Tagify(document.getElementById('singleValueSelectTagify'), {
enforceWhitelist: true,
mode: 'select',
whitelist: ['tag1', 'tag2', 'tag3'],
dropdown: {
closeOnSelect: true, // Close the dropdown when a suggestion is selected
maxItems: Infinity,
},
});