Answer the question
In order to leave comments, you need to log in
How to add data to vue.js model after ajax request?
here is the html code
<select class="selectpicker" name="car[automodel_id]" disabled title="{{Lang::get('nav.car_model')}}">
<option v-for="models in models" value="@{{model.id}}">@{{model.title}}</option>
</select>
Vue.http.headers.common['X-CSRF-TOKEN'] = document.querySelector('meta[name="_token"]').getAttribute('content');
new Vue({
el : 'nav',
data :{
models : [],
},
methods :{
brands : function ( e ) {
this.$http.post(Website.href + 'cars/models/' + e.target.value, function (obj){
this.models = obj.models;
});
}
}
});
Answer the question
In order to leave comments, you need to log in
It can be like this:
methods :{
brands : function ( e ) {
var vue = this;
this.$http.post(Website.href + 'cars/models/' + e.target.value, function (obj){
vue.models = obj.models;
});
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question