Reputation: 481
I'm new in mvc. I have to display a model dialog box.. but it shows an error like this.. the code should be shown below..
in view
<div class="demo">
<div id="dialog-modal" title="Basic dialog">
</div>
<button id="opener">Open Dialog</button>
</div>
<script type="text/javascript">
$(function () {
$('#dialog').dialog({
autoOpen: false,
width: 400,
resizable: false,
title: 'hi there',
modal: true,
buttons: {
"Close": function () {
$(this).dialog("close");
}
}
});
$('#opener').click(function () {
//Load the CreateAlbumPartial action which will return
// the partial view _CreateAlbumPartial
$('#dialog').load('@Url.Action("PartialTest")',
function (response, status, xhr) {
$('#dialog').dialog('open');
});
});
});
</script>
in controller
//[HttpGet]
public PartialViewResult Test()
{
//List<string> category_lst = new List<string>();
//category_lst = (from r in db.dept select r.dname).ToList();
return PartialView(db.dept.ToList());
}
Upvotes: 0
Views: 24678
Reputation: 106
It looks like there's a mismatch in your IDs for the dialog DIV.
Try changing the JS to this:
$('#dialog-modal').dialog({
Upvotes: 2
Reputation: 24312
You need to add following references to the page
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
Update
In your comment, you are doing it totally wrong. Make your code like following and remove other references.
BundleConfig,
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
"~/Scripts/jquery-ui-{version}.js"));
Layout,
@Styles.Render("~/Content/themes/base/css")
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryui")
Upvotes: 5