Skip to content

Commit 0bd65aa

Browse files
committed
Fixes facebook#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.
1 parent 2981bef commit 0bd65aa

File tree

1 file changed

+14
-1
lines changed
  • examples/jquery-bootstrap/js

1 file changed

+14
-1
lines changed

examples/jquery-bootstrap/js/app.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@ var BootstrapModal = React.createClass({
1919
componentDidMount: function() {
2020
// When the component is added, turn it into a modal
2121
$(this.refs.root).modal({backdrop: 'static', keyboard: false, show: false});
22+
23+
// Bootstrap's modal class exposes a few events for hooking into modal
24+
// functionality. Lets hook into one of them:
25+
$(this.refs.root).on('hidden.bs.modal', this.handleHidden);
2226
},
2327
componentWillUnmount: function() {
24-
$(this.refs.root).off('hidden', this.handleHidden);
28+
$(this.refs.root).off('hidden.bs.modal', this.handleHidden);
2529
},
2630
close: function() {
2731
$(this.refs.root).modal('hide');
@@ -84,6 +88,11 @@ var BootstrapModal = React.createClass({
8488
if (this.props.onConfirm) {
8589
this.props.onConfirm();
8690
}
91+
},
92+
handleHidden: function() {
93+
if (this.props.onHidden) {
94+
this.props.onHidden();
95+
}
8796
}
8897
});
8998

@@ -102,6 +111,7 @@ var Example = React.createClass({
102111
cancel="Cancel"
103112
onCancel={this.handleCancel}
104113
onConfirm={this.closeModal}
114+
onHidden={this.handleModalDidClose}
105115
title="Hello, Bootstrap!">
106116
This is a React component powered by jQuery and Bootstrap!
107117
</BootstrapModal>
@@ -120,6 +130,9 @@ var Example = React.createClass({
120130
},
121131
closeModal: function() {
122132
this.refs.modal.close();
133+
},
134+
handleModalDidClose: function() {
135+
alert("The modal has been dismissed!");
123136
}
124137
});
125138

0 commit comments

Comments
 (0)