marek marek - 5 months ago 48
React JSX Question

How to hide "react-bootstrap modal" form that has preventDefault() inside its onSubmit?

The problem is that when I do not use preventDefault(), page is reloaded onSubmit and hidden. When preventDefault is used my form is doing what it has in onSubmit, but it is not hiding after submit. When I use other "Close" button that has only


form is hiding just fine.

How to hide that form when it is done with its onSubmit.

<Modal {...this.props} className="adressModal" bsStyle="primary" title='Adress Form' animation={false}>
<form className="addressModal" onSubmit={this.handleSubmit} >
<div className="modal-body">
<Input type="text" placeholder="Enter Kraj" className="form-control" valueLink={this.linkState('address')} ref="address" hasFeedback required/>
<div className="modal-footer">
<Button className="btn btn-default" onClick={this.props.onRequestHide} data-dismiss="modal" active>Close</Button>
<Button bsStyle="primary" className="btn btn-default" type="submit" disabled={this.state.isSubmitting} >Save</Button>

Code is just mix of ModalTrigger example from
and React basic tutorial


You could just call the this.props.onRequestHide function inside of the handleSubmit function

something like this:

handleSubmit: function() {
  /* ... */