// Simple pure-React component so we don't have to remember // Bootstrap's classes var BootstrapButton = React.createClass({ render: function() { return ( ); } }); var BootstrapModal = React.createClass({ // The following four methods are the only places we need to // integrate with Bootstrap or jQuery! componentDidMount: function() { // When the component is added, turn it into a modal $(this.getDOMNode()) .modal({backdrop: 'static', keyboard: false, show: false}) }, componentWillUnmount: function() { $(this.getDOMNode()).off('hidden', this.handleHidden); }, close: function() { $(this.getDOMNode()).modal('hide'); }, open: function() { $(this.getDOMNode()).modal('show'); }, render: function() { var confirmButton = null; var cancelButton = null; if (this.props.confirm) { confirmButton = ( {this.props.confirm} ); } if (this.props.cancel) { cancelButton = ( {this.props.cancel} ); } return (

{this.props.title}

{this.props.children}
{cancelButton} {confirmButton}
); }, handleCancel: function() { if (this.props.onCancel) { this.props.onCancel(); } }, handleConfirm: function() { if (this.props.onConfirm) { this.props.onConfirm(); } } }); var Example = React.createClass({ handleCancel: function() { if (confirm('Are you sure you want to cancel?')) { this.refs.modal.close(); } }, render: function() { var modal = null; modal = ( This is a React component powered by jQuery and Bootstrap! ); return (
{modal} Open modal
); }, openModal: function() { this.refs.modal.open(); }, closeModal: function() { this.refs.modal.close(); } }); React.render(, document.getElementById('jqueryexample'));