samedi 27 juin 2015

Bootstrap modal disappearing in ASP MVC 5, and not from double loading bootstrap

I'm toggling a model from Javascript, but it disappears immediately. I'm not loading bootstrap-modal (which is one of the problems people have). Also, I tried eliminating bootstrap.min.js, and that didn't fix it either. I tried .modal(), .modal('show') and .modal('toggle'). Also, this was a VisualStudio initialized MVC project, so I didn't put in place all the jquery and bootstrap loads.

Modal

<div id="confirmAddedToInventoryModal" class="modal fade" role="dialog">
    <div class="modal-dialog">

        <!-- Modal content-->
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">Item Added to Inventory</h4>
            </div>
            <div class="modal-body">
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>

    </div>
</div>

Javascript

<script type="text/javascript">
    $(document).ready(function () {
        $('#create-form').on('submit', function () { $('#confirmAddedToInventoryModal').modal('toggle') });
    })
</script>

Aucun commentaire:

Enregistrer un commentaire