Reputation:
I created a simple react modal but when i click modal content it also close it.
I have a wrapper div with class modal_wrapper
which change background of body when modal is open and when i click anywhere in this div modal is closed.
But modal is also closed when i click anywhere of modal_content
div.
How can i stop closing the modal when i click inside modal_content
div ?
Upvotes: 0
Views: 1376
Reputation: 692
You need to stop click event propagation. In dont_close_modal function, capture the click event and then you can stop the propagation like this.
dont_close_modal:function(e) {
e.stopPropagation()
this.setState({
open_modal:true
})
},
Upvotes: 1