safetyduck
safetyduck

Reputation: 6874

Vue clickthrough event is not getting triggered

I have a chart inside a Vue directive. I want to catch the click through event, do something, and pass it through as usual.

Putting the following:

v-on:click="clickThrough($event)"

with

methods: {
  clickThrough: function (event) {
    var a = 1
    return event
  }
}

And a breakpoint at the var a = 1.

However the breakpoint does not get hit. Something else must be catching the click event.

Any ideas on how to debug this?

Upvotes: 1

Views: 114

Answers (1)

Dan
Dan

Reputation: 63119

Try:

v-on:click.native="clickThrough($event)"

From the docs:

There may be times when you want to listen directly to a native event on the root element of a component. In these cases, you can use the .native modifier for v-on

Child components have to emit an event for the parent component to catch it in a listener, and no such click event is emitted by the custom component. This is unlike a non-component element such as a plain div sitting directly in the parent, which does emit the event. So .native is there for exactly this situation.

Upvotes: 1

Related Questions