Anamnian
Anamnian

Reputation: 427

Dialog is not a function in MVC 5

My _layout.cshtml contains:

<link href='@Url.Content("~/Content/themes/base/all.css")' rel="stylesheet" type="text/css" />
<link href='@Url.Content("~/Content/themes/base/jquery-ui.css")' rel="stylesheet" type="text/css" />
<script src='@Url.Content("~/Scripts/jquery-ui-1.12.0.min.js")' type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-1.12.4.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-ui-1.12.0.js")" type="text/javascript"></script>

In Index.cshtml try to:

<div id="dialog_1">
    <label>Something</label>
</div>
<script> 
    $(function () {
        $("#dialog_1").dialog();    
})</script>

Get: Uncaught TypeError: $(...).dialog is not a function.

Upvotes: 0

Views: 4743

Answers (2)

Anamnian
Anamnian

Reputation: 427

Solved my problem: after including jQuery UI package need bundle the required files and refer to the bundles.

Upvotes: 1

Dhara Parmar
Dhara Parmar

Reputation: 8101

Either include minified version of jquery ui file or actual version of file, you have added both - that is wrong:

Either remove "~/Scripts/jquery-ui-1.12.0.js" or "~/Scripts/jquery-ui-1.12.0.min.js"

Try this:

<link href='@Url.Content("~/Content/themes/base/all.css")' rel="stylesheet" type="text/css" />
<link href='@Url.Content("~/Content/themes/base/jquery-ui.css")' rel="stylesheet" type="text/css" />
<script src='@Url.Content("~/Scripts/jquery-ui-1.12.0.min.js")' type="text/javascript"></script>
<script src='@Url.Content("~/Scripts/jquery-1.12.4.js")' type="text/javascript"></script>

Upvotes: 0

Related Questions