Home > DeveloperSection > Forums > How to stop closing of Bootstrap modal popup outside click
Pawan Shukla

Total Post:37

Points:267
Posted on    September-30-2014 7:54 AM

 Bootstrap Bootstrap  CSS-CSS3  HTML  JQuery 
Ratings:


 1 Reply(s)
 7489  View(s)
Rate this:
I have a bootstrap modal popup in my application, it closes when i click on outside of modal popup, I only want that modal popup closes on click of cross button and close button

below is my code:

<div class="container">

    <br />

    <br />

    <button class="btn btn-primary" id="launchmodal" data-toggle="modal" data-target="#myModal">

        Launch demo modal

    </button>

</div>

 

<!-- Modal -->

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

    <div class="modal-dialog">

        <div class="modal-content">

            <div class="modal-header">

                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>

                <h4 class="modal-title" id="myModalLabel">Modal title</h4>

            </div>

            <div class="modal-body">

                ...

            </div>

            <div class="modal-footer">

                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>

                <button type="button" class="btn btn-primary">Save changes</button>

            </div>

        </div>

    </div>

</div>

Here is my javascript code:

<script>

    $(document).ready(function () {

        $('#launchmodal').click(function () {

            $('#myModal').modal({

                keyboard: false

            })

        });

    });

 </script>



Kamlakar Singh
Kamlakar Singh

Total Post:194

Points:1396
Supported
Posted on    September-30-2014 8:02 AM

Hi pawan shukla
i'm solve your problem you can use this code

<script>

    $(document).ready(function () {

        $('#launchmodal').click(function () {

            $('#myModal').modal({

                backdrop: 'static',

                keyboard: false,

            })

        });

 

    });

</script>


Don't want to miss updates? Please click the below button!

Follow MindStick