I have a select in a form, and the items in this select are populated dynamically by vue.js.
My problem is that when I open a saved database in the database for editing on this form, I need to have some items selected according to what was saved before, and I do not know how to do this.
If someone knows about another library that looks like vue.js that is as light as it is easy to use, I also accept suggestions.
Here is my code:
var setores = new Vue({
el: '#v-for-negociossetores',
data: {
setoresitens: {"countcats":16,"countsubcats":56,"catsubcatsdata":{"123":{"titulo":"Alimentos","descricao":"Padarias, Mercados, Restaurantes, Lanchonetes e etc.","subcats":{"345":{"codurl":"restaurantes","titulo":"Restaurantes","descricao":""}}},"abc":{"titulo":"Religiões","descricao":"","subcats":{"def":{"codurl":"igrejas","titulo":"Igrejas","descricao":""},"ghi":{"codurl":"religiao-casas","titulo":"Casas","descricao":""},"jkl":{"codurl":"religiao-templos","titulo":"Templos","descricao":""},"mno":{"codurl":"religiao-terreiros","titulo":"Terreiros","descricao":""}}}}}
}
});
<script src="https://cdn.jsdelivr.net/npm/vue"></script><divclass="row clearfix">
<div class="col-sm-3">
<div class="form-group" id="v-for-negociossetores">
<select name="codsetores[]" class="form-control show-tick" multiple title="Setores">
<optgroup v-for="(group, keygroup) in setoresitens.catsubcatsdata" v-bind:label="group.titulo">
<option v-for="(option, keyoption) in group.subcats" v-bind:value="keyoption">
{{ option.titulo }}
</option>
</optgroup>
</select>
</div>
</div>
</div>