C
C
claus_bor2018-04-06 14:17:38
JavaScript
claus_bor, 2018-04-06 14:17:38

How to continue bubbling an event?

there are two elements:

<export-data :data="data"><button></button></export-data>

export-data is a component that, when clicked, will export the xls file. I wrapped my button with this component to style it. By clicking on the button, I need to stop the bubbling, make a request to the server to collect the data, push it into data, and continue bubbling so that the click is processed on export-data. Is there any way in js to keep bubbling after stopPropagation?
PS project on vue.js

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2018-04-06
@claus_bor

Try after the actions taken, it will start the event again. On an element this.$elor parent, call dispatchEvent.
That is, you cannot stop the event and then continue it. Will have to call it again. https://developer.mozilla.org/docs/Web/Guide/Event...

<template>
  <div @click="clicked">...</div>
</template>

<script>
export default {
  ...
  methods: {
    clicked(ev) {
      const savedEvent = ev;
      ev.stopPropagation();
      // ... что-то на сервере
      this.$el.dispatchEvent(savedEvent);
    }
  }
};
</script>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question