The Bootstrap modular window does not close

advertisements

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.


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