http://react-bootstrap.github.io/components.html#modals - 我正在寻找一种方法来找到“shown.bs.modal”而不是“show.bs.modal”的触发事件。
我没有看到有关某些引导模式事件的任何文档: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'));
我什至试图通过在 jQuery 中将它放在一边来破解它,这也不起作用。
<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>
知道如何触发“显示”事件吗?我在 react-bootstrap 源中也找不到任何东西。