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

145
Views
triggering click event from class in vuejs

I am using vuejs. I want a this method to get triggered whenever anything with a specific class is clicked. I am having trouble setting it up in vuejs, but had it working correctly with vanilla js. Please take a look

new Vue({
  el: "#app",
  data: {
 
  },
  methods: {
 handleTileClick: function(){
  alert("You have got mail")

window.top.$("body").append(`<div>My Div goes here!</div>`);


const tiles = document.querySelectorAll(".carousel-cell-card")

tiles.forEach(tile => tile.addEventListener('click', handleTileClick))
   }
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
  <h2>Checklist:</h2>
  <p class="carousel-cell-card">
  my friend bob
  </p>
</div>

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You need to initialize the listeners in the mounted section

new Vue({
  el: "#app",
  mounted() {
   const tiles = document.querySelectorAll(".carousel-cell-card");
   tiles.forEach(tile => tile.addEventListener('click', this.handleTileClick))
  },
  methods: {
   handleTileClick(){
     alert("You have got mail");
     //window.top.$("body").append(`<div>My Div goes here!</div>`); // This statement has to be debugged
   }
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
  <h2>Checklist:</h2>
  <p class="carousel-cell-card">
  my friend bob
  </p>
</div>

over 4 years ago · Santiago Trujillo 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!