Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modal is transitioning error with bootstrap4 alpha6 modal

I am using bootstrap4 alpha 6 Modal, I am getting:

Error: Modal is transitioning

That happen when I am trying to re-trigger the same modal again with dynamic data through JavaScript function as following:

function openModal(title, text) {
    $('.modal-title').text(title);
    $('.modal-body p').text(text);
    $('#modalAlert').modal('show');
}

I tried to use setTimeout function, but didn't work as in this article: https://github.com/twbs/bootstrap/issues/21687

Any suggestions?

like image 324
CairoCoder Avatar asked Apr 06 '17 22:04

CairoCoder


People also ask

How can I show data using a modal when clicking a table row using bootstrap?

On each of your <tr> 's add a data attribute for id (i.e. data-id ) with the corresponding id value and specify a data-target , which is a selector you specify, so that when clicked, bootstrap will select that element as modal dialog and show it.

How do I edit a bootstrap modal?

<button type="button" class="btn btn-sm btn-primary fas fa-pencil-alt noUnderlineCustom text-white" data-toggle="modal" data-target="#editModal"></button> This is a HTML code that compose the editing button. data-toggle="modal" This attribute activates the Bootstraps Modal without using JS.

What is Modals in bootstrap modal?

Modals are built with HTML, CSS, and JavaScript. They're positioned over everything else in the document and remove scroll from the <body> so that modal content scrolls instead. Clicking on the modal “backdrop” will automatically close the modal. Bootstrap only supports one modal window at a time.

How do I open bootstrap modal in center of screen?

Answer: Use the CSS margin-top Property This solution will dynamically adjust the alignment of the modal and always keep it in the center of the page even if the user resizes the browser window.


1 Answers

Worked with removing fade from parent div class.

Final Modal code ( Adding here for posterity ) :

HTML

<div class="modal loadingModal" id="applemodal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"  aria-hidden="true">
          <div class="modal-dialog" role="document">
              <div class="modal-body">
                <div class="row">
                    <div class="col-md-6">
                    </div>
                    <div class="col-md-6">
                        <img src="ico/4.svg">
                    </div>
                </div>
              </div>
          </div>
    </div>

JS

$.ajax({
        type: "GET",
        url: "/getTimeline",
        data: {
            'dateTime': selected
        },
        async: true,
        beforeSend: function () {
              $('#applemodal').modal({
                  backdrop: 'static',
                  keyboard: false
              });
        },
        success: function(data) {
            $('#applemodal').modal('toggle');
       }
});
like image 96
jinetjose Avatar answered Sep 22 '22 02:09

jinetjose