Reputation: 166
I have problem. Can't get value from select using vue strap select.
My html code:
<bs-select
v-model="select.value"
:options="select.options"
options-value="val"
justified
close-on-select
placeholder="Chose action"
@change="contract_corresponds_activity"
></bs-select>
I tried :value.sync except v-model as well.
My js code:
import {input, checkbox, select, option} from 'vue-strap'
export default {
components: {
'bs-select': select,
},
data () {
return {
select: {
options: [
{val: 0, label: 'unknown'},
{val: 1, label: 'plus 1'},
{val: 2, label: 'plus 2'},
{val: 4, label: 'plus 4'},
{val: 6, label: 'plus 6'}
],
value: ''
}
},
methods: {
some_function () {
alert(this.select.value)
axios.post(this.api_url + this.$route.params.id + '/domgmt', { value: this.select.value
}).then(response => {
this.update_form_data(response.data)
}).catch(error => {
this.errors = error.response.data.errors
})
}
}
This code gave me select option, but i cant save it to variable value. My post request is empty string, same as my alert gives me nothing. My goal is to send value: 1, 2, 4, 6 or 0.
Upvotes: 0
Views: 152
Reputation: 166
The problem is that i should add parametr to on change event so code will look like:
some_function (value) {
alert(value)
axios.post(this.api_url + this.$route.params.id + '/domgmt', { value: value
}).then(response => {
this.update_form_data(response.data)
}).catch(error => {
this.errors = error.response.data.errors
})
}
In that case it will show what i've clicked just now
Upvotes: 0