http://react-bootstrap.github.io/components.html#modals - I am looking for a way to find the trigger event for 'shown.bs.modal' and not 'show.bs.modal'.
I don't see any documentation on some of the bootstrap modal events: http://getbootstrap.com/javascript/#modals-events
var NewPerson = React.createClass({
getInitialState: function(){
return { showModal: false };
},
componentDidMount: function() {
// removed irrelevant code
},
close: function(){
this.setState({ showModal: false });
},
open: function(){
this.setState({ showModal: true });
},
submit: function(e) {
// removed irrelevant code
},
render: function() {
var Button = ReactBootstrap.Button;
var ButtonInput = ReactBootstrap.ButtonInput;
var Modal = ReactBootstrap.Modal;
return (
<div>
<Button
className="pull-right bottom-20"
bsStyle='success'
bsSize='large'
onClick={this.open}
>
Create New Person
</Button>
<Modal id="new-person-modal" show={this.state.showModal} onHide={this.close}>
<Modal.Header closeButton>
<Modal.Title>Create a New Person!</Modal.Title>
</Modal.Header>
<Modal.Body>
<form id="new-person-form" onSubmit={this.submit} accept-charset="UTF-8" method="POST" novalidate="novalidate">
<div className="row">
<div className="form-group col-md-12">
<input type="text" className="form-control" id="author" name="author" ref="author" placeholder="Author (First + Last)" required />
</div>
</div>
<ButtonInput
type="submit"
value="Submit"
bsStyle="success"
bsSize="large"
onSubmit={this.submit}
disabled={this.state.disabled} />
</form>
</Modal.Body>
</Modal>
</div>
);
}
});
React.render(<NewPerson url="/person" />, document.getElementById('person-new'));
I even tried to hack it by just doing it in jQuery off to the side, which also isn't working.
<script type="text/javascript">
$(document).ready(function() {
$('#new-person-modal').on('shown.bs.modal', function (e) {
console.log('modal displayed');
// now can execute dynamic JS
});
});
</script>
Any idea how to trigger the 'on shown' event? I can't find anything in the react-bootstrap source either.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…