admirhusic
6 months ago
1279
1
Vue

Double click and single click on same element in Vue.js

Posted 6 months ago by admirhusic

I want to implement something like instagram does on photos. When the user clicks on the photo the app opens the current post, but when the user double clicks on the photo it triggers a like.

    <a :href="'p/'+ post.id" >
          <img class="card-img-top w-100"  :src="post.image_path" />
    </a>

if I do it like this

   <a @dblclick="likeThePost(post.id)"  :href="'p/'+ post.id" >
          <img class="card-img-top w-100" :src="post.image_path" />
        </a>

it opens the post and triggers the like in the same time

Please sign in or create an account to participate in this conversation.