54
rated 0 times
[
57]
[
3]
/ answers: 1 / hits: 12053
/ 5 Years ago, thu, july 25, 2019, 12:00:00
I get an error.
I have added some code and would like to my code to get to know why
its not working.
I can't use react-strap. Please suggest if we can use Bootstrap modal in react.
I get an error.
I have added some code and would like to my code to get to know why
its not working.
I can't use react-strap. Please suggest if we can use Bootstrap modal in react.
Below is my code
import React from 'react';
import $ from 'jquery';
window.jQuery = $;
window.$ = $;
global.jQuery = $;
class Modal extends React.Component {
constructor(props) {
super(props);
}
componentDidMount() {
$('#myModal').on('shown.bs.modal', function () {
$('#myInput').trigger('focus');
});
}
render()
{
return (
<div>
<div className="bd-example">
//Button code
<button type="button" className="btn btn-primary " data-toggle="modal" data-target="#exampleModalLive">
Launch demo modal</button>
//Modal code
<div className="modal" id="exampleModalLive" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div className="modal-dialog modal-dialog-centered" role="document">
<div className="modal-content">
<div className="modal-header">
<h5 className="modal-title" id="exampleModalCenterTitle">Modal title</h5>
<button type="button" className="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div className="modal-body">
...
</div>
<div className="modal-footer">
<button type="button" className="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" className="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
</div>
</div>
);
}
}
export default Modal;
More From » jquery