Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tag-added event not triggering if value is added programatically #146

Open
Marchiuzzz opened this issue Jun 15, 2021 · 0 comments
Open

Tag-added event not triggering if value is added programatically #146

Marchiuzzz opened this issue Jun 15, 2021 · 0 comments

Comments

@Marchiuzzz
Copy link

I'm not sure if this is a bug or if I'm doing something wrong or perhaps that's the intended behavior but if I have a setup like this:

<template>
    <div>
        <tags-input element-id="tags"
            v-model="selectedTags"
            :existing-tags="availableTags"
            :before-adding-tag="checkIfExists"
            typeahead-style="dropdown"
            placeholder="Tags"
            @tag-removed="remove"
            @tag-added="add"
            :typeahead="true" v-if="!loading"></tags-input>
    </div>
</template>
<script>
import Tag from '../Models/Tag'
export default {
    ...
    data(){
        return {
            tagLabel: 'tags',
            tagInput: '',
            selectedTags: [],
            loading: true,
        }
    },
    methods:{
        checkIfExists(item){
            if(!item.key){
                if(confirm(window.translate('dictionary.addNewTag'))){
                    axios.post('/api/tags/create', {tagname: item.value})
                    .then(response => {
                        var respTag = response.data.data;
                        Tag.insert({
                            data: respTag
                        });
                        this.selectedTags.push(respTag);
                    });
                }
                return false;
            }else{
                return true;
            }
        },
    }
}
</script>

As you can see, I append a new tag to tags list with this line this.selectedTags.push(respTag); however, it does not fire a "tag-added" event

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant