samedi 24 août 2019

How to pre select vue-select

I'm working on vue-select.. i can save vue-select vue in database...when i edit form vue-select not selected by v-model value..

guest_title.id" :label="guest_title" :class="{ 'is-invalid': form.errors.has('guest_type') }" >

export default { name: "EditGuestComponent", mounted(){ $(function () { //Initialize Select2 Elements $('.select2').select2() }) this.$store.dispatch("allGuestTitle") this.$store.dispatch("allGuestDesignation") this.$store.dispatch("allStaffs") axios.get(`/api/edit-guest/${this.$route.params.id}`) .then((respose) => { this.form.fill(respose.data.guest) }) }, computed:{ getAllGuestTitle(){ return this.$store.getters.getGuestTitle }, getAllGuestDesignation(){ return this.$store.getters.getGuestDesignation }, getAllStaff(){ return this.$store.getters.get_staffs }, }, data(){ return { form: new Form({ branch:'', id:'', name:'', guest_type:'', designation:'', rf_staff:'', rf_guest:'', email_address:'', alt_email_address:'', phone_number:'', alt_phone_number:'', address:'', status:'1' }) } }, methods:{ updateGuest(){ console.log(this.form.guest_type) this.form.post('/api/update-guest') .then((response) => { this.form.branch = '' this.form.id = '' this.form.name = '' this.form.guest_type = '' this.form.designation = '' this.form.rf_staff = '' this.form.rf_guest = '' this.form.email_address = '' this.form.alt_email_address = '' this.form.phone_number = '' this.form.alt_phone_number = '' this.form.address = '' this.form.status = '' this.$router.push('/guest-list') Toast.fire({ type: 'success', title: ' Guest Updated successfully' }) }) } } }

via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire