M
M
Maxim Zolotoy2019-04-14 19:51:22
JavaScript
Maxim Zolotoy, 2019-04-14 19:51:22

How to track click on shadow in modal window using VUE?

There is a modal window, a cross to close it and a shadow. If you hang the handler on the root element of the modal window, then it will close when you click on the window itself, which is not necessary. How to be?

<template>
  <transition name="modal">
    <div v-if="status" class="modal-wrap">
      <div class="inner-wrap">
        <div class="modal-window">
          <div class="close-cross" @click="closeModal">
            <i class="fas fa-times"></i>
          </div>
          <slot></slot>
        </div>
      </div>
    </div>
  </transition>
</template>

5cb36503725a5721860779.jpeg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
0
0xD34F, 2019-04-14
@spacenear

First, google what event bubbling is.
Secondly - have you heard about event modifiers ? It would be necessary to fasten self - this is if on the "shadow". Or stop - on the window.

D
Dima Pautov, 2019-04-14
@bootd

https://www.npmjs.com/package/vue-click-outside

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question