I have created in my vue component the following template
<b-button v-on:click="check($event)" class="btn btn-success" data-action="consent">
<b-icon-check></b-icon-check>
</b-button>
However the click event only seems to work if I click on the button itself, for example on the sides around the icon, and not when clicking on the icon itself.
I'm wondering if there's a better way to do what I want to achieve instead of adding another v-on:click on the icon itself.
Basically I want the button to trigger the click event even if any subelement it has is clicked.
Here's the function check(event)
methods:{
check(event){
let action = event.target.getAttribute('data-action');
if(action === 'consent'){
this.checked = true;
}
else{
this.checked = false;
}
}
},
After reading the comments and the link for modifiers, I think my mistake is assuming that the event.target
is going to be the button. Instead it's the icon itself that's why my code is failing.