Skip to content
Browse files

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.
  • Loading branch information...
1 parent 2981bef commit 0bd65aa028461c450fad66db16a3b9f27af38332 @MarkMurphy MarkMurphy committed
Showing with 14 additions and 1 deletion.
  1. +14 −1 examples/jquery-bootstrap/js/app.js
View
15 examples/jquery-bootstrap/js/app.js
@@ -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!");
}
});

0 comments on commit 0bd65aa

Please sign in to comment.
Something went wrong with that request. Please try again.