0

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());
        }
2
  • Exactly. 'It shows an error like this' what is the error it shows? Commented Jun 12, 2013 at 5:36
  • Error is in the title :) Commented Jun 12, 2013 at 5:53

2 Answers 2

5

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")
Sign up to request clarification or add additional context in comments.

1 Comment

<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" <script src="../../Scripts/jquery-1.5.1.min.js" type="text/javascript"></script> <script src="../../Scripts/jquery1.8.0.js" type="text/javascript"></script> <script src="../../Scripts/jquery-1.9.1.js" type="text/javascript"></script> <script src="../../Scripts/jquery-1.10.3-ui.js" type="text/javascript"></script> <link href="../../Content/themes/base/images/jquery-ui.css" rel="stylesheet" type="text/css" />
2

It looks like there's a mismatch in your IDs for the dialog DIV.

  • the HTML uses "dialog-modal"
  • the JS uses "dialog"

Try changing the JS to this:

    $('#dialog-modal').dialog({

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.