Hi all
I am hoping someone can help with this. "Also my approach maybe wrong as I am new to Laravel & Vue."
I have 2 question's / issues's.
First if that I am not getting the selected value from a select/option list.
The second is the when I click on the Add button the record is add but the screen is not refreshing, so how do I refresh a page from within a Vue component?
Here is the code... on the page I am referencing the Vue component with -
<contact-numbers :data="{{ $listing }}"></contact-numbers>.
and here is the Vue component...
Phone / Email / Web: list
Choose type...
<small>Enter: Phone / Email / Web</small>
<input id="item" class="form-control" required v-model="item">
<br>
<div class="pull-right">
<button type="submit" class="btn btnrow btn-row" @click="addContactNumber">Add</button>
</div>
<br>
<hr>
<div v-for="contactNumber in contactNumbers.data">
{{ contactNumber.type }}: {{ contactNumber.item }}
<hr>
</div>
</div>
</div>
</div>
</div>
export default {
props: ['data'],
data() {
return {
id: this.data.id,
slug: this.data.slug,
item: '',
type: '',
itemTypes: ['Office', 'Mobile', 'Direct', 'Home', 'Email', 'Website'],
contactNumbers: [
]
};
},
created(){
axios.get('/contact-number-list/' + this.data.slug)
.then(({data}) => this.contactNumbers = data);
},
methods: {
addContactNumber() {
axios.post('/contact-number/create/' + this.data.slug , {
id: this.id,
item: this.item,
type: this.type
})
.catch(error => {
flash(error.response.data, 'danger');
})
.then(({data}) => {
this.item = '';
this.type = '';
flash('Your contact number has been added.');
this.$emit('created', data);
});
},
}
}
Thank Chris