forum

Home / DeveloperSection / Forums / How to stop closing of Bootstrap modal popup outside click

How to stop closing of Bootstrap modal popup outside click

Anonymous User1532830-Sep-2014
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:

<divclass="container">
    <br/>
    <br/>
    <buttonclass="btn btn-primary"id="launchmodal"data-toggle="modal"data-target="#myModal">
        Launch demo modal
    </button>
</div>
 
<!-- Modal -->
<divclass="modal fade"id="myModal"tabindex="-1"role="dialog"aria-labelledby="myModalLabel"aria-hidden="true">
    <divclass="modal-dialog">
        <divclass="modal-content">
            <divclass="modal-header">
                <buttontype="button"class="close"data-dismiss="modal"><spanaria-hidden="true">&times;</span><spanclass="sr-only">Close</span></button>
                <h4class="modal-title"id="myModalLabel">Modal title</h4>
            </div>
            <divclass="modal-body">
                ...
            </div>
            <divclass="modal-footer">
                <buttontype="button"class="btn btn-default"data-dismiss="modal">Close</button>
                <buttontype="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>


Updated on 30-Sep-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By