0

I would like to block the user from exiting the modal on clicking outside or pressing ESC when an input has been changed, my attempt being:

$("#cadastroModal input, #cadastroModal textarea, #cadastroModal select").on('change input select select2:select', function() {
   $('#cadastroModal').attr('data-backdrop', 'static');
   $('#cadastroModal').attr('data-keyboard', false);
});

And while the element does change in runtime (as checked with chrome inspect element), it seems like it doesn't respect the data attributes if its already open. How can I fix this?

Mathias Hillmann
  • 1,537
  • 2
  • 13
  • 25

1 Answers1

0

Apparently you need to use _config as shown here

This worked:

$('#cadastroModal').data('bs.modal')._config.backdrop = 'static';
$('#cadastroModal').data('bs.modal')._config.keyboard = false;
Mathias Hillmann
  • 1,537
  • 2
  • 13
  • 25