D
D
DGretOu2021-01-26 19:24:30
JavaScript
DGretOu, 2021-01-26 19:24:30

How to implement opening a modal window with Bootstrap, waiting for it to close before that?

There is a modal window that opens as a result of an Ajax request. The modal window provides a choice of components and 2 buttons, after which the modal window closes, another Ajax request is sent and the same modal window opens again.

The problem is that when I try to open it again, it does not have time to close from the last time and as a result is not displayed. How can this be resolved? How can I wait for the window to completely close and then send a new request, or send a request and when trying to open check / wait for closing to open.

$('.button-without-component-send').on('click', function () {
      modalComponents.modal('hide');
      sendComponents();
    });

    $('.button-component-send').on('click', function () {
      modalComponents.modal('hide');
      currentPackage += 1;
      sendComponents('Название');
    });

    function sendComponents(name = '') {
      $.ajax({
      ........
      modalComponents.modal('show');
      })

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JavaDev, 2021-01-26
@DGretOu

Don't be lazy and read the documentation:
eng - https://getbootstrap.com/docs/4.5/components/modal...
rus - https://bootstrap-4.ru/docs/4.5/components/modal/#...

$('#myModal').on('hidden.bs.modal', function (e) {
  // do something...
})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question