I have the following code in my view:
<div>
<div v-for="(solicitacao, $index) in solicitacoes">
<div class="box-image" :class="{'box-rejected' : solicitacao.$$reprovado}">
<div class="box-image-header">
@{{ solicitacao.usuario.nome }}
</div>
<div class="box-image-body">
<img :src="solicitacao.foto_link" src="https://placehold.it/300x400"></div><divclass="box-image-footer">
<button class='wgm-btn wgm-btn-red' type="button" v-on:click="reprovar(solicitacao, $index)">
Reprovar
</button>
<button class='wgm-btn wgm-btn-blue' type="button" v-on:click="aprovar(solicitacao)">
Aprovar
</button>
</div>
<div class="box-image-overlay"></div>
</div>
</div>
</div>
I get the solicitacoes
variable through an Ajax
new Vue({
el: '#vue-gerenciar-fotos',
data: {
carregando: true,
ficha_tecnica_id: undefined,
solicitacoes: []
},
mounted: function () {
this.ficha_tecnica_id = $(this.$el).data('fichaTecnicaId');
this.carregarSolicitacoes(1);
},
methods: {
carregarSolicitacoes: function (page) {
var that;
that = this;
that.carregando = true;
$.get('/solicitacao/ajax-aguardando-aprovacao-foto/' + this.ficha_tecnica_id, {page: page}, function (response) {
Array.prototype.push.apply(that.solicitacoes, response.solicitacoes);
that.carregando = false;
if (page != response.last_page) {
that.carregarSolicitacoes(++page);
}
});
},
reprovar: function (solicitacao, $index) {
solicitacao.$$reprovado = true;
},
aprovar: function (solicitacao) {
solicitacao.$$aprovado = true;
}
},
});
When I click on the "Disapprove" button, the reprovar
function is called (I even did tests on the Console). However, even setting solicitacao.$$reprovado
to true
, nothing happens in View.
I should modify the class to box-reject
as soon as I clicked the button, since the $$reprovado
value was added.
Why is the View value not being updated? No Angular would work smoothly.
What do you need to do to work adding a new value to the object solicitacao
that is in v-for
?