Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

136
Views
Vue @click.stop still getting the child component

I want to get the child elements of the parent component.

<div
    v-on:click.stop.prevent="onClickTemplateHandler">
    <div>
    <h3 style="">Title</h3>
    <p>{{ lorem }}</p>
    </div>
</div>


...


onClickTemplateHandler(e) {
    console.log(e)
    const innerHTML = e.target.innerHTML
    if (innerHTML) {
      this.value += innerHTML
    }
} 

I've tried to use .self, but I still want the inner of the div be clickable

But, when I click the inside of the div, I am getting the child as the target instead of the parent.

Any suggestion for this one?

Thanks!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I did some workaround

<div>
    <div class="overlay" v-on:click.stop.prevent="onClickTemplateHandler"></div>
    <div>
      <h3 style="padding: 10px;text-align: center;">Header</h3>
    </div>
</div>


...

onClickTemplateHandler(e) {
    const innerHTML = e.target.nextElementSibling.innerHTML
    if (innerHTML) {
      this.value += innerHTML
    }
}

...

.overlay {
    position: absolute;
    width: 100%;
    height: 100%;
    left: 0px;
    z-index: 2;
    top: 0px;
    cursor: pointer;
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!