Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
53
rated 0 times [  55] [ 2]  / answers: 1 / hits: 35767  / 8 Years ago, mon, january 25, 2016, 12:00:00

I've got some custom components in Vue.js. In one of the components I have is a select list that I want to render as a Chosen select box. I use this with a jQuery function $(select).chosen().



<template v-for=upload in uploads>
<new-upload-container :index=$index :upload=upload v-if=isNewUpload></new-upload-container>
<existing-upload-container :index=$index :upload=upload v-if=isExistingUpload></existing-upload-container>
</template>


After I add data to the uploads bound array in the Vue instance, the view updates with an instance of the component. Unfortunately when I try to instantiate Chosen on the select field, it doesn't work.



I'm not sure if it takes a short time after I add an item to the uploads bound array that the DOM actually updates.



<template id=existing-upload-container>

<select name=beats[@{{ index }}][existing_beat] class=existing-beats>
<option selected=selected value=>-- Select a linked beat --</option>
@foreach ($beats as $beat)
<option value={{$beat->id}}>{{$beat->name}}</option>
@endforeach
</select>

</template>


Is there an event that is triggered after a component has been fully rendered?


More From » vue.js

 Answers
34

You could try two things in your component, based on which one works with your package. In the Vue object:



{
ready:function(){
// code here executes once the component is rendered
// use this in the child component
},
watch: {
uploads:function(){
//code here executes whenever the uploads array changes
//and runs AFTER the dom is updated, could use this in
//the parent component
}
}
}

[#63568] Saturday, January 23, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
shaina

Total Points: 161
Total Questions: 99
Total Answers: 108

Location: American Samoa
Member since Fri, Sep 24, 2021
3 Years ago
;