0

I'm creating my modal with the escape key and backdrop disabled by default

$(modal).modal({
  backdrop: "static",
  keyboard: false
});

Then some time later I wanna enable them

$(modal).modal({
  backdrop: true,
  keyboard: true
});

But when I click on the backdrop or press escape nothing happens. I could recreate the entire modal but that looks broken, clumsy and hacky. How do I do this properly?

php_nub_qq
  • 15,199
  • 21
  • 74
  • 144
  • Maybe https://stackoverflow.com/questions/11806816/change-bootstrap-modal-option-once-it-already-exists can help you – Tan Duong May 02 '18 at 10:06

1 Answers1

1

I figured out boostrap 4 change structure of configuration. You should use

$('#basicModal').data('bs.modal')._config.keyboard = true;
$('#basicModal').data('bs.modal')._config.backdrop = true;

See the https://codepen.io/anon/pen/rvmvQB

Tan Duong
  • 2,124
  • 1
  • 11
  • 17