Vue

by holoverse

HTML

<div id="app">
  <h2>Items:</h2>
  <ol>
    <li v-for="item, key in todos" >
      <a href='#' @click="clickMe(key)" :ref="'item'+key"> {{item.text}}</a>
    </li>
    <button v-for="item, key in todos" @click="triggerClick(key)">
      {{key}}
    </button>
  </ol>
</div>

CSS

body {
  background: #20262E;
  padding: 20px;
  font-family: Helvetica;
}

#app {
  background: #fff;
  border-radius: 4px;
  padding: 20px;
  transition: all 0.2s;
}

li {
  margin: 8px 0;
}

h2 {
  font-weight: bold;
  margin-bottom: 15px;
}

del {
  color: rgba(0, 0, 0, 0.3);
}

Vue

new Vue({
  el: "#app",
  data: {
    todos: [
      { text: "Learn JavaScript", done: false },
      { text: "Learn Vue", done: false },
      { text: "Play around in JSFiddle", done: true },
      { text: "Build something awesome", done: true }
    ]
  },
  methods: {
    clickMe(key){
     console.log(key)
    },
    triggerClick(key){
      let link = "item"+key
      // I have the element apparently
      console.log(this.$refs[link])
     // Now I just wanna trigger a click on it for fuck sakes 
      this.$refs[link].click()
    }
  }
})