Answer the question
In order to leave comments, you need to log in
How to get information about the parent block when clicking on the child?
I have a product card on which the v-on:click="heandler($event)" handler is hung. In the handler, the target and id of the card on which the click was made are pulled out from the event object. But when a child element is clicked, a nested element that does not have an id gets into target, and I cannot determine which card was clicked on. Is there a way to pass the parent element to the event?
Answer the question
In order to leave comments, you need to log in
Instead of target , use currentTarget .
But it's not clear at all - what prevents you from immediately passing the id of the card (or the entire object) to the click handler?
Use the .self modifier
Then event.target will contain the element on which you hung the handler
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question