Reputation: 1145
I am using Bootstrap modal in a react application . I have a requirement that the modal window should not close when clicking on modal backdrop . For this I am using
$(".modal").modal("backdrop":"static");
which works perfectly fine . But in the next scenario , I want the same modal to close on clicking on backdrop using the following code.
$(".modal").modal("backdrop":true);
But this is not working .
I tried this too
$('#modal').modal('hide');
Please provide a feasible solution for the same.
Upvotes: 0
Views: 1296
Reputation: 2010
When you pass an object to the modal
function, you can pass these properties
For closing the modal, you should use $(".modal").modal("hide")
link
Upvotes: 1
Reputation: 1956
To close bootstrap modal you can pass 'hide' as option to modal method as follow
$('#modal').modal('hide');
Bootstrap also provide events that you can hook into modal functionality, like if you want to fire a event when the modal has finished being hidden from the user you can use hidden.bs.modal event you can read more about modal methods and events here in Documentation
Upvotes: 1