Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/411.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ASP.NET MVC jquery对话框\u布局_Javascript_Jquery_Asp.net_Asp.net Mvc - Fatal编程技术网

Javascript ASP.NET MVC jquery对话框\u布局

Javascript ASP.NET MVC jquery对话框\u布局,javascript,jquery,asp.net,asp.net-mvc,Javascript,Jquery,Asp.net,Asp.net Mvc,我一直在遵循这个教程:直到对话框正常工作为止。但是,我不知道为什么对话框没有打开 它没有打开对话框,而是注入了我在MVC应用程序的_布局中定义的内容,这实际上扩展了我在页面顶部的导航栏。但是,我认为,因为脚本正在调用.dialog,所以它会按照ui脚本中的定义打开对话框 我的_布局代码: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" c

我一直在遵循这个教程:直到对话框正常工作为止。但是,我不知道为什么对话框没有打开

它没有打开对话框,而是注入了我在MVC应用程序的_布局中定义的内容,这实际上扩展了我在页面顶部的导航栏。但是,我认为,因为脚本正在调用.dialog,所以它会按照ui脚本中的定义打开对话框

我的_布局代码:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - Spare Part Application</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
<link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
<link href="~/Content/ui-darkness/jquery-ui-1.10.4.custom.css" rel="stylesheet" type="text/css" />
<script src="../../Scripts/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-ui-1.8.2.custom.min.js" type="text/javascript">      </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("Parts On Hand","Index","PartOnHands")</li>
                <li>@Html.ActionLink("VMI","Index","VMIOnHands")</li>
                <li><a href='javascript:showVolumeConstants();'>Set Volume</a></li>
            </ul>
            <script type="text/javascript">

                function showVolumeConstants() {
                    if($('#editVolume').length ==0)
                    {
                        //ajax load
                        $('#volumeScreen').load("@Url.Action("OpenVolume","Home")");
                    } else {
                        // reopen the volume dialog which was previously rendered
                        $("#editVolume").dialog("open");
                    }
                }
            </script>
        </div>
        <div id='volumeScreen'>
        </div>
    </div>
</div>
<div class="container body-content">

    @RenderBody()
    <hr />
    <footer>
        <p>&copy; @DateTime.Now.Year - SeaInv</p>
    </footer>
</div>
以下是我的部分观点:

@using System.Web

<div id='editVolume' style="height:150px;">
<h1 style="color:whitesmoke">Edit Volume</h1>
<table>
    <tr>
        <td style="color:ghostwhite">6 Month Volume:</td>
        <td>@Html.TextBox("volume6month")</td>
    </tr>
    <tr>
        <td style="color:ghostwhite">Quarter Volume:</td>
        <td>@Html.TextBox("volumeQuarter")</td>
    </tr>
 </table>
 </div>
<script type="text/javascript">
$(function () {
    $("#editVolume").dialog({
        model: true,
        autoOpen: true,
        resizeable: false,
        buttons: [{
            Submit: function () {
                // Edit the volumes entered
                $.post("@Url.Action("EditVolume","Home")",
                    {
                        volume6month: $("volume6month").val(),
                        volumeQuarter: $("volumeQuarter").val()
                    },
                    function (data, status, xhr) {
                        if (data.Success) {
                            $('#editVolume').dialog("close");
                        } else {
                            //Do something
                        }
                    });
            },
            Cancel: function () {
                $(this).dialog("close");
            }
        }]
    });
});
</script>
任何帮助都将不胜感激

下面是我的对话框代码当前的功能。。。不是我想要的行为,而且没有按钮。我不明白在我的代码中添加这个jqueryUI文件或jqueryUI脚本有什么不对,我变得非常沮丧。有人能帮忙吗


编辑:最后要提到的是,我在_布局中有部分视图渲染,但它是由HomeController控制的。但是我不认为这是一个问题。

您是否确保控制器上的OpenVolume方法返回的是部分视图而不是视图?如果没有,它将在默认情况下运行_ViewStart,它通常将布局定义为视图的一部分。我觉得这与javascript库没有正确加载有关,但我不确定如何检查,也不知道为什么不能正确加载。嗨,阿弗,我把对话框中的按钮和div作为_布局的一部分。。。这是问题的一部分吗?我是否需要将空div放在单独的页面中?但我希望它能在所有屏幕上加载,这就是我的问题所在。我仍然认为jQueryUI没有被加载,它的css似乎也与之相连。任何人都可以提供任何建议或帮助,即使只是为了开始调试它?