Borna Marin
Borna Marin

Reputation: 113

Add modifier to v-on in menu activator using Vuetify

Simplified example:

<v-list>
  <v-list-item :to="bla/bla">
    <v-menu>
      <template v-slot:activator="{on}">
        <v-btn v-on.prevent="on"/> // I tried .stop, .stop.prevent, self.prevent, prevent.stop
      </template>
      <div> bla </div>
    <v-menu>   
  </v-list-item>
</v-list>

So as you can see child event v-on triggers v-menu and shows this div. But it also triggers parent :to event. Any ides?

Upvotes: 4

Views: 1747

Answers (2)

Thomas Kuhlmann
Thomas Kuhlmann

Reputation: 1003

You are using the event modifier on v-on, no on v-on.click.

You can stop the propagation by adding @click with the modifier separately to the button:

<v-btn v-on="on" @click.stop.prevent />

Upvotes: 2

Boussadjra Brahim
Boussadjra Brahim

Reputation: 1

Try to destruct the on slot prop as follows :

  <template v-slot:activator="{ on: { click } }">
        <v-btn  v-on:click.stop.prevent="click">
          open
          </v-btn>
      </template>

Upvotes: 6

Related Questions