I created a MVC 5 application using the template from VS 2013.
This does not come with jQuery UI so I added 1.11.1 version using PM. No reason for that version but found a tutorial on YouTube using that.
The Contents folder looks like this:
The Scripts folder looks like this:
I want to work with the modal pop-up that jQuery UI offers so just to try out modified _Layout.cshtml:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - My ASP.NET Application</title>
@Styles.Render("~/Content/css")
<link href="~/Content/themes/base/dialog.css" rel="stylesheet" />
@Scripts.Render("~/bundles/jquery")
<script src="~/Scripts/jquery-ui.min-1.11.1.js"></script>
@Scripts.Render("~/bundles/modernizr")
<script>
$(function () {
$("#dialog-modal").dialog({
width: 400,
height: 200,
modal: true
});
});
</script>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
@Html.ActionLink("Application name", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>@Html.ActionLink("Home", "Index", "Home")</li>
<li>@Html.ActionLink("About", "About", "Home")</li>
<li>@Html.ActionLink("Contact", "Contact", "Home")</li>
</ul>
</div>
</div>
</div>
<div class="container body-content">
@RenderBody()
<hr />
<footer>
<p>© @DateTime.Now.Year - My ASP.NET Application</p>
</footer>
</div>
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
</body>
</html>
This is the modal div in Index.cshtml:
<div id="dialog-modal" title="Schedule Preview" style="display:none">
<p>This is empty preview</p>
</div>
The modal does pop-up when the site loads but it's messed up beyond description. So here is a screenshot with the pop-up marked in red.
Can someone please guide me on what's going on here and how to fix it?
Thanks in advance.
Using the version of jQuery that uses separate JS/CSS files for the various components, you need to load more that just
dialog.css
. From a custom build, toggling only the dialog, it looks like you need:If you also only want to load the individual JavaScript files, you need:
If you'd rather simplify this, you can just load
all.css
(and possiblytheme.css
), though you'll run into conflicts with Bootstrap, if you're using it.