Jquery Dialog无法在mvc3应用程序上打开

时间:2013-03-24 01:33:42

标签: asp.net-mvc-3 jquery-ui-dialog

我在使用razor的mvc3上有一个简单的应用程序在我打开对话框之前我试图打开一个“警报”并且它正常工作所以它的功能正在处理事件但当我评论此警报时 尝试打开它不起作用的对话框

@model MvcApplication1.Models.LogOnModel

@{
    ViewBag.Title = "Create";
}

<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>    
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.11.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>

<link href="@Url.Content("~/Content/themes/base/jquery.ui.all.css")" rel="stylesheet" type="text/css" />

<h2>Index</h2>

<script type="text/javascript">
    $(document).ready(function () {

        $('#dialog').dialog({
            autoOpen: false,
            width: 400,
            resizable: false,
            title: 'hi there',
            modal: true,

            buttons: {
                "Close": function () {
                    $(this).dialog("close");
                }
            }
        });

        $('#contactForm').submit(function (e) {
            //alert("entro a funcion");
            e.preventDefault();
            $('#dialog').dialog('open');
        });

    });
</script>



@using (Html.BeginForm("Index", "Infracciones", FormMethod.Post, new { id = "contactForm"}))
{
@Html.ValidationSummary(true)
    <fieldset>
        <legend>Infraccion</legend>

      </fieldset>
    <p>
    <input value="Guardar" type="submit" name = "button"/>
    </p>
}

2 个答案:

答案 0 :(得分:1)

您只需要添加:

<div id="dialog">

在体内。

答案 1 :(得分:0)

尝试:

$('#dialog').dialog();

而不是

$('#dialog').dialog('open');