I found a solution. JQuery library must be declared before bootstrap library. It seems that there is an order to follow or something like that.
Bootstrap 3.1.1 doesn't work on MVC3 View page
-
21-07-2023 - |
Вопрос
I am new in MVC.NET and I have this problem:
I'm trying to create a simple button that shows a Bootstrap modal dialog but it doesn't work. The bootstrap version is 3.1.1 and jquery 1.9.0.
_Layout.cshtml references:
<script type="text/javascript" src="@Url.Content("~/Scripts/js/bootstrap.min.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/js/jquery-1.9.0.js")"></script>
<link rel="Stylesheet" type="text/css" href="@Url.Content("~/Content/css/bootstrap.min.css")"/>
<link rel="Stylesheet" type="text/css" href="@Url.Content("~/Content/css/bootstrap-theme.min.css")" />
Index.cshtml code:
<div class="container">
<h2>Example of creating Modals with Twitter Bootstrap</h2>
<div id="example" class="modal fade" style="display: none;" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3>This is a Modal Heading</h3>
</div>
<div class="modal-body">
<h4>Text in a modal</h4>
<p>You can add some text here.</p>
</div>
<div class="modal-footer">
<a href="#" class="btn btn-success">Call to action</a>
<a href="#" class="btn" data-dismiss="modal">Close</a>
</div>
</div>
</div>
</div>
<p> <a data-toggle="modal" href="#example" class="btn btn-primary btn-large">Launch demo modal</a>
</p>
</div>
The .css file is loaded because I can see that the styles are applied but bootstrap.js or jquery aren't and the dialog doesn't show up.
Решение
Не связан с StackOverflow