bootstrap modal popup not closing

38,219

Solution 1

There was indeed javascript conficting with the closing of the popup. There was a line of javascript messing with all popups when clicking on a parent container, forcing them open again.

Solution 2

This one worked for me

$('#popupDelete').modal('toggle');

Solution 3

I'm not sure if this is causing the problem, but there is a typo. It's

<div class="modal-body">

in line 3. There is missing an "l"

Share:
38,219
dreagan
Author by

dreagan

Developer for Prosteps, a development agency in Belgium. I mostly use Node.js, Coldfusion, MongoDB and a little bit of SQL.

Updated on April 06, 2022

Comments

  • dreagan
    dreagan about 2 years

    I'm having trouble using a bootstrap modal popup. Calling a popup is no issue, but trying to close it yields strange results. Instead of just hiding the popup and removing the backdrop, the popup gets hidden but another backdrop gets added, turning the screen almost black. the original backdrop does not get removed.

    Below is the html code I've tried to use

    <div id="popupDelete" class="modal hide fade" role="dialog">
        <div class="modal-header">delete transaction line?</div>
        <div class="moda-body">
            <button id="deleteYes">yes</button>
            <button class="cancelButton" data-dismiss="modal">no</button>
        </div>
    </div>
    

    this is what I got from the bootstrap 2.3 docs and should work out of teh bix, like everything else from bootstrap.

    I've also tried using javascript with the $('#popupDelete').modal('hide'); function, which had the same effect.

    • notan3xit
      notan3xit over 10 years
      I just tried your code in my application and it works. Maybe some of your other JS interferes?
  • Granny
    Granny over 6 years
    Try to backup your answer with an explanation or documentation. This will help the person asking the question to understand what he/she did wrong.
  • Craigoh1
    Craigoh1 about 6 years
    but how did you fix it? what was the line of code you needed to change?