Open antonreshetov opened 4 years ago
Actually, I kind of figured it out. I created a new tag using the createTag
helper. Then I called the addTag
method by ref from <vue-tag-input>
add pass new tag as argument.
The question can be considered closed. The only thing we would like to see is as a method in the API of the component
import VueTagsInput, { createTag } from '@johmun/vue-tags-input';
let tag = createTag(tagName, [tagName]);
this.$refs.tags.addTag(tag);
@kdeegan And how to use createTag method if I used component as plugin?
import Vue from 'vue'
import VueTagsInput from '@johmun/vue-tags-input'
Vue.use(VueTagsInput)
Jumping in having spent at least half a day banging my head why programmatically adding a tag via the helper wasn't working out for me. It's kinda funny/weird but when prop 'add-only-from-autocomplete' is set to true manually created tags won't be added. Switched the the prop to false everything rolled out as planned.
ps: IMHO this is not a desirable behaviour since programmatically added tags do not concern user input, therefore don't have to be whitelisted. Manual tag creation could bypass this check.
@pskarlas Yes, problem is in addTag method, because they have some rules before adding, as u said, if 'add-only-from-autocomplete' is true, saving is not done. The best way to figure things out is to download their project and look through JS file
I use the custom dropdown as a suggestion. Is there any way to add a tag programmatically?