Fixes #5959 - jquery-bootstrap example uses which does not exist
1. Add a handleHidden method to the BootstrapModal component. 2. Add an event listener for 'hidden.bs.modal' on the modal root 3. Add a new onHidden prop to the BootstrapModal component. 4. Add a new 'handleModalDidClose' method to the Example component to be used as the onHidden prop of it's modal component.
This commit is contained in:
parent
2981bef075
commit
0bd65aa028
|
@ -19,9 +19,13 @@ var BootstrapModal = React.createClass({
|
|||
componentDidMount: function() {
|
||||
// When the component is added, turn it into a modal
|
||||
$(this.refs.root).modal({backdrop: 'static', keyboard: false, show: false});
|
||||
|
||||
// Bootstrap's modal class exposes a few events for hooking into modal
|
||||
// functionality. Lets hook into one of them:
|
||||
$(this.refs.root).on('hidden.bs.modal', this.handleHidden);
|
||||
},
|
||||
componentWillUnmount: function() {
|
||||
$(this.refs.root).off('hidden', this.handleHidden);
|
||||
$(this.refs.root).off('hidden.bs.modal', this.handleHidden);
|
||||
},
|
||||
close: function() {
|
||||
$(this.refs.root).modal('hide');
|
||||
|
@ -84,6 +88,11 @@ var BootstrapModal = React.createClass({
|
|||
if (this.props.onConfirm) {
|
||||
this.props.onConfirm();
|
||||
}
|
||||
},
|
||||
handleHidden: function() {
|
||||
if (this.props.onHidden) {
|
||||
this.props.onHidden();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -102,6 +111,7 @@ var Example = React.createClass({
|
|||
cancel="Cancel"
|
||||
onCancel={this.handleCancel}
|
||||
onConfirm={this.closeModal}
|
||||
onHidden={this.handleModalDidClose}
|
||||
title="Hello, Bootstrap!">
|
||||
This is a React component powered by jQuery and Bootstrap!
|
||||
</BootstrapModal>
|
||||
|
@ -120,6 +130,9 @@ var Example = React.createClass({
|
|||
},
|
||||
closeModal: function() {
|
||||
this.refs.modal.close();
|
||||
},
|
||||
handleModalDidClose: function() {
|
||||
alert("The modal has been dismissed!");
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue