bootstrap modal does not work

Asked

Viewed 7,539 times

0

<div class="modal fade" id="addhor" role="dialog" >
            <div class="modal-dialog">
                <div class="modal-content">
                        <div class="modal-header">
                            <h4>Adicionar Horário</h4>
                        </div>
                    <div class="modal-body">
                        <p>teste</p>
                    </div>

                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div><!-- /.modal -->

I saw this example as modal in bootstrap, the modal opens but, does not work shows the content with a dark screen and when I click anywhere it closes. Someone could help me?

P.S.: Excuse the mistakes of Portuguese, my keyboard does not have accents

  • 1

    Calling the modal via Javascript: $('#addhor').modal() works smoothly. Can be more specific about the problem?

1 answer

4


For the modal to work there must be an event that in the case of this example was the button event data-toggle="addhor".

<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#addhor">

Launch modal demo

You can also show the modal using javascript

$('#addhor').modal('show');

If none of these examples work, the bootstrap javascript file is not inserted in the page.

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>

For more details please read the documentation of Bootstrap Modals.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.