Can I have call onclick when after append html in vuejs, I using vue-append
this.html = '<div id="' folderData[key].id '" >'
'<a href="#" style="color:black" data-toggle="tooltip" title="' textTooltip '"> '
'<div >'
'<span v-on:click="gofolder(' folderData[key].id ')" ></span>'
'<div v-on:click="gofolder(' folderData[key].id ')" >' textName '</div>'
checkbox
'</div>'
'</a>'
'</div>'
<template>
<div v-append.sync="html" >
</div>
</template>
CodePudding user response:
Can you just listen to @appended
event?
<div v-append.sync="html" @appended="onClickHandler" ></div>
CodePudding user response:
I using v-for and an array to load, problem solved! Firstly, I will not using vue-append and create a frames html and using v-for to create a list follow array data, because my list data will changes if I click in button Ex:
<div >
<div :id="item.id" v-for="item in items" :key="item.id">
<a href="#" style="color:black" data-toggle="tooltip" :title="item.tooltip">
<div >
<span @click="gofolder(item.id)" :></span>
<div @click="gofolder(item.id)" >{{item.textName}}</div>
<input v-if="item.checkbox === true" type="checkbox" value="">
</div>
</a>
</div>
</div>
specifically here: v-for="item in items" :key="item.id"
after, I can call event onclick on buttons then not be afraid it will take the wrong value