From 0bd65aa028461c450fad66db16a3b9f27af38332 Mon Sep 17 00:00:00 2001 From: Mark Murphy Date: Mon, 1 Feb 2016 20:32:32 -0400 Subject: [PATCH] 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. --- examples/jquery-bootstrap/js/app.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/examples/jquery-bootstrap/js/app.js b/examples/jquery-bootstrap/js/app.js index f4539227ed..c1342d82a7 100644 --- a/examples/jquery-bootstrap/js/app.js +++ b/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! @@ -120,6 +130,9 @@ var Example = React.createClass({ }, closeModal: function() { this.refs.modal.close(); + }, + handleModalDidClose: function() { + alert("The modal has been dismissed!"); } });