Aatif Bandey
Aatif Bandey

Reputation: 1145

Bootstrap modal window does not close

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

Answers (2)

Zamboney
Zamboney

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

Jijo Paulose
Jijo Paulose

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

Related Questions