Closed kickthemooon closed 6 years ago
Can you share your code? I have tried to replicate your issue but couldn't.
<div id="app">
<h3>
Vue Trumbowyg v3 demo
</h3>
<button @click.prevent="add">
Add another
</button>
<button @click.prevent="remove">
Remove
</button>
<div v-for="(object, index) in objects">
<button @click.prevent="reset(index)">
Reset content
</button>
<trumbowyg v-model="object.content" :config="config" class="editor"> </trumbowyg>
</div>
</div>
Vue.component('Trumbowyg', VueTrumbowyg.default);
new Vue({
el: '#app',
data: {
objects: [{
content: '1'
}, {
content: '2'
}],
config: {
}
},
mounted() {
console.log('app mounted')
},
methods: {
add() {
this.objects.push({
content: 'Time: ' + +new Date()
})
},
remove() {
this.objects.splice(-1)
},
reset(index) {
this.objects[index].content = '';
}
}
});
Thank you very much for the example,
What I actually am trying to do is reset the whole array. That means if there 5 objects on the array, I want to remove them all and then add a default one again.
I was trying to achieve that with this.objects = [{content: ''}];
and that is where I am left with "naked" textareas.
Finally I found out what it is thanks to your example.
my v-for
was like this:
<trumbowyg
:config="tbwgConfig"
v-for="textElement in textElements"
v-model="textElement.content"
></trumbowyg>
and yours was wrapped inside a div so after I wrapped mine inside a div and moved the v-for
inside the div the issue was gone.
Thanks.
I'm submitting a ...
Tell about your platform
Current behavior I have an array of objects in my data and use this component with
v-for
. When I push a new object to the array everything is fine, a new trumbowyg editor appears.The problem arises when I do
this.objects = [{content: ''}]
. So on reset of the object array trumbowyg is gone but a "naked" textarea is still there.Expected behavior That nothing is left after I reset the object area.
Minimal reproduction of the problem with instructions
v-for
on this component