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.
Mark Murphy committed
Feb 1, 2016 at 20:32 UTC
0bd65aa028461c450fad66db16a3b9f27af38332
1 file changed
+14
-1
examples/jquery-bootstrap/js/app.js
+14
-1
@@ -19,9 +19,13 @@ var BootstrapModal = React.createClass({
19
componentDidMount: function() {
20
// When the component is added, turn it into a modal
21
$(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);
26
},
27
componentWillUnmount: function() {
24
- $(this.refs.root).off('hidden', this.handleHidden);
28
+ $(this.refs.root).off('hidden.bs.modal', this.handleHidden);
29
},
30
close: function() {
31
$(this.refs.root).modal('hide');
@@ -84,6 +88,11 @@ var BootstrapModal = React.createClass({
88
if (this.props.onConfirm) {
89
this.props.onConfirm();
90
}
91
+ },
92
+ handleHidden: function() {
93
+ if (this.props.onHidden) {
94
+ this.props.onHidden();
95
+ }
96
}
97
});
98
@@ -102,6 +111,7 @@ var Example = React.createClass({
111
cancel="Cancel"
112
onCancel={this.handleCancel}
113
onConfirm={this.closeModal}
114
+ onHidden={this.handleModalDidClose}
115
title="Hello, Bootstrap!">
116
This is a React component powered by jQuery and Bootstrap!
117
</BootstrapModal>
@@ -120,6 +130,9 @@ var Example = React.createClass({
130
},
131
closeModal: function() {
132
this.refs.modal.close();
133
+ },
134
+ handleModalDidClose: function() {
135
+ alert("The modal has been dismissed!");
136
}
137
});
138