admin管理员组文章数量:1278789
I'm using Vuetify and I have v-data-table
. When I click on row v-dialog
must open. Also I have v-switch
inside rows in my v-data-table
. My problem es when I click on the v-switch
it switches, but also propagates and opens my v-dialog
.
In my codepen I have three examples of v-switch click events.
- First is with
@click.native.stop
. Here I deal with propagation successfully, but click event is not only in the v-switch, but it covers the whole container (colored in red in example) - My second try is with
@change
. Here switch event is activated only on v-switch toggle, but when I click on the v-switch the v-dialog opens too. So with@change
it doesn't work properly too. - The third try is with
@change.stop
, but without desired result, its same as my second try.
My question is - Is there a way to stop the propagation (with no side effects as in my first example) and when I click on v-switch to toggle only the switch , but not and the v-dialog behind?
I'm using Vuetify and I have v-data-table
. When I click on row v-dialog
must open. Also I have v-switch
inside rows in my v-data-table
. My problem es when I click on the v-switch
it switches, but also propagates and opens my v-dialog
.
In my codepen I have three examples of v-switch click events.
- First is with
@click.native.stop
. Here I deal with propagation successfully, but click event is not only in the v-switch, but it covers the whole container (colored in red in example) - My second try is with
@change
. Here switch event is activated only on v-switch toggle, but when I click on the v-switch the v-dialog opens too. So with@change
it doesn't work properly too. - The third try is with
@change.stop
, but without desired result, its same as my second try.
My question is - Is there a way to stop the propagation (with no side effects as in my first example) and when I click on v-switch to toggle only the switch , but not and the v-dialog behind?
Share Improve this question asked Apr 13, 2020 at 17:08 stanimirspstanimirsp 3,1062 gold badges29 silver badges42 bronze badges2 Answers
Reset to default 7Just add @click.native.stop
to your <v-switch>
.
See it working: https://codepen.io/andrei-gheorghiu/pen/RwWPONL
Note: To limit the area in which the click is captured, you have to change .v-input--switch
s display
value to inline-block
:
.v-input--switch {
display: inline-block;
}
And you don't actually need to stop more than click
, as the dialog only opens on click. As you can see, you can use Tab + Space to toggle the switch and the modal is not opening.
My workaround is to use @click.native.stop
to stop propagation and @change
for event
<v-switch
v-model="item.isActive"
@click.native.stop
@change="toggleActive(item)">
</v-switch>
本文标签: javascriptHow to stop propagation in Vuetify vswitchStack Overflow
版权声明:本文标题:javascript - How to stop propagation in Vuetify v-switch? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741273349a2369587.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论