How to open popup, onclick of link in Vuejs?

Viewed 4741

 <label class="label-set">
 <input type="checkbox" class="" name="sameadr" />
  I agree to all statements of
  <a href="#" style="color: #ee1d24"> Terms of Use </a>
  </label>

How to open popup, onclick of link. simple popup should open as soon as user click on link

2 Answers

In html give a id to your a tag.

    <label class="label-set" id="mainId">
     <input type="checkbox" class="" name="sameadr" />
      I agree to all statements of
      <a href="#" id="newId" style="color: #ee1d24"> Terms of Use </a>
    </label>

In javascript

    document.getElementById("newId").addEventListener("click", function(){
       confirm("confirm this") // or your popop code
    })

Try this for vue.js

<a href="javascript:void(0)" v-on:click="openPopup" id="newId" style="color: #ee1d24"> Terms of Use </a>

And write this inside your method

    new Vue({
      el: '#mainId',
      methods: {
        openPopup: function () {
          alert('ok')
        }
      }
    })

Try this

Make a modal component. Add a click to your a tag. When clicked show your modal component. After another action (confirm etc.) close and continue.

How to make a reusable modal component in Vue.js: How to make a Modal Component

Related