I've seen this question Bootstrap tagsinput add tag with id and value, but the solution is not working for me:
What I'm finding is that in order to get the input box recognising tags that I type in, I either have to have data-role = tagsinput OR call $("input").tagsinput().
eg. This works for recognising tags with no data-role:
$('#meeting-tags').tagsinput();
$('#meeting-tags').tagsinput({
allowDuplicates: false,
itemValue: 'id', // this will be used to set id of tag
itemText: 'label' // this will be used to set text of tag
});
But this does not:
$('#meeting-tags').tagsinput({
allowDuplicates: false,
itemValue: 'id', // this will be used to set id of tag
itemText: 'label' // this will be used to set text of tag
});
However, if I want to add items via javascript then it will only work if I neither have data-role nor have an initial call. The error is Can't add objects when itemValue option is not set
eg. this works but now it doesn't recognise tags:
$('#meeting-tags').tagsinput({
allowDuplicates: false,
itemValue: 'id', // this will be used to set id of tag
itemText: 'label' // this will be used to set text of tag
});
$('#meeting-tags').tagsinput('add', { id: 'tag id', label: 'tag lable' });
but this does not but now it recognises tags again:
$('#meeting-tags').tagsinput();
$('#meeting-tags').tagsinput({
allowDuplicates: false,
itemValue: 'id', // this will be used to set id of tag
itemText: 'label' // this will be used to set text of tag
});
$('#meeting-tags').tagsinput('add', { id: 'tag id', label: 'tag lable' });
There must surely be a way of BOTH being able to recognise tags and add items?