Plugin initialized with 2 options:
- tags (Array) Custom tags
- autocomplete:values (Array) values for the autocomplete list
- autocomplete:only (Boolean) Means that only values of the above list are authorized
- create (Boolean|Function) Event called after adding a tag
Documentation
Basic usage
Initialize plugin with custom tags
Allows you to add custom tags on plugin initialization.
$('#tags').inputTags({
tags: ['jQuery', 'tags', 'plugin'] // Custom tags list
});
Advanced usage
Initialize plugin with tags autocomplete
Allows you to add a custom list from which the user can choose one or more tags.
$('#tags').inputTags({
init:function($elem) {
console.log('Event called on plugin init', $elem);
},
create:function() {
console.log('Event called when an item is created');
},
update:function() {
console.log('Event called when an item is updated');
},
destroy:function() {
console.log('Event called when an item is deleted');
},
selected:function() {
console.log('Event called when an item is selected');
},
unselected:function() {
console.log('Event called when an item is unselected');
},
change:function($elem) {
console.log('Event called on item change', $elem);
},
autocompleteTagSelect:function($elem) {
console.log('Event called on tag selection', $elem);
}
});
Add events after plugin initialization
$('#tags').inputTags().on('change', function($elem) {
console.log('Event called on item change', $elem);
});
same as:
$('#tags').inputTags('event', 'change', function($elem) {
console.log('Event called on item change', $elem);
});