admin管理员组文章数量:1401780
I have a Post
ponent which basically render's a card. If the post is clicked, then the URL should route to '/expand/'
.
Now I have another ponent called DeleteTemplate
which renders a button and clicking it render's a Modal.
Now, I have used this DeleteTemplate
in my Post
ponent.
Now, clicking the DeleteTemplate
button is rendering the Modal. In the Modal if i select the Cancel
option, the URL is getting routed to '/expand/'
which shouldn't be happening.
I have a Post
ponent which basically render's a card. If the post is clicked, then the URL should route to '/expand/'
.
Now I have another ponent called DeleteTemplate
which renders a button and clicking it render's a Modal.
Now, I have used this DeleteTemplate
in my Post
ponent.
Now, clicking the DeleteTemplate
button is rendering the Modal. In the Modal if i select the Cancel
option, the URL is getting routed to '/expand/'
which shouldn't be happening.
1 Answer
Reset to default 4The click events of the buttons in your modal are bubbling up to the card. You need to add event.stopPropagation()
to the onClick
handlers of those buttons inside the modal.
So in your DeleteTemplate
render function:
<Button color="secondary" onClick={this.cancel}>
CANCEL
</Button>
with the cancel handler looking like this:
cancel(event) {
event.stopPropagation();
this.toggleModal();
}
Working example:
本文标签: javascriptReactjseventstopPropagation not workingStack Overflow
版权声明:本文标题:javascript - Reactjs - event.stopPropagation not working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744323173a2600602.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论