Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bootstrap-vue checkbox prevent change if certain condition is met

I am using the bootstrap-vue package and have a checkbox as follows:

<b-form-checkbox v-model="isSelected"switch></b-form-checkbox>

i have data property

data(){
    isSelected: false
}

what i would like to do is for user to click the checkbox and before the checked value is changed is to perform some sort of validation by calling a method. The method may then prevent the value being changed.

How can i do this?

I have tried to bind method to the @change event but then when i try to set this.isSelected = false the checkbox value is still checked.

like image 965
JimmyShoe Avatar asked Jan 01 '23 18:01

JimmyShoe


1 Answers

I finally achieved it using @click.native.prevent

like image 139
franciscorode Avatar answered Jan 13 '23 12:01

franciscorode