Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/394.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
C# 色盒延迟打开和;锁;加载外部Java脚本文件时_C#_Javascript_Asp.net_Asp.net Mvc 3_Colorbox - Fatal编程技术网

C# 色盒延迟打开和;锁;加载外部Java脚本文件时

C# 色盒延迟打开和;锁;加载外部Java脚本文件时,c#,javascript,asp.net,asp.net-mvc-3,colorbox,C#,Javascript,Asp.net,Asp.net Mvc 3,Colorbox,我正在使用colorbox在我的项目中加载模式页面。 当我点击打开一个模式时,页面需要一段时间来加载,窗口在一段时间内“锁定”。 我做了一个简单的页面来表示我的问题。 访问: 当您单击Index2时,页面加载正常,但当您单击模态链接时,模态加载需要一段时间(请注意,加载图像会锁定一段时间)。 如果打开ChromeDevTools并选择network选项卡,您将看到加载到modal窗口的外部js文件需要一段时间才能加载。 在我的示例中,加载窗口需要一段时间,但是,如果我尝试加载3个或更多js文件,

我正在使用colorbox在我的项目中加载模式页面。 当我点击打开一个模式时,页面需要一段时间来加载,窗口在一段时间内“锁定”。 我做了一个简单的页面来表示我的问题。 访问: 当您单击Index2时,页面加载正常,但当您单击模态链接时,模态加载需要一段时间(请注意,加载图像会锁定一段时间)。 如果打开ChromeDevTools并选择network选项卡,您将看到加载到modal窗口的外部js文件需要一段时间才能加载。 在我的示例中,加载窗口需要一段时间,但是,如果我尝试加载3个或更多js文件,则加载模式窗口可能需要10秒或更长的时间

Index2页面的代码和加载模式的脚本:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Index2
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript">
    $(document).ready(function () {
        $('.cbox').colorbox({
            innerWidth: 833,
            innerHeight: 500,
            scrolling: true
        });
    });
    </script>
    <a href="/Home/Modal" class="cbox">Modal</a>
</asp:Content>

模态代码:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Modal.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<script type="text/javascript" src="<%= ResolveUrl("~/Scripts/ScriptFile.js") %>"></script>


    <h2>Modal</h2>

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="HeaderContent" runat="server">
</asp:Content>

情态动词

知道为什么会这样吗?

在Looonnggg搜索之后,我找到了解决方案:

ColorBox使用jQuery的load()方法进行ajax处理,因此您只需将所需的选择器添加到链接的href

$(document).ready(function () {
     $('.cbox').colorbox({
         href: function () {
             return $(this).attr('href');
         },
         innerWidth: 833,
         innerHeight: 500,
         scrolling: true
     });
 });
林克布顿:

<%: Html.ActionLink("Add", "Create", "Agenda", new { @class = "btn btn-mini pull-left margin-10 no-margin-left border-radius-3 cbox" })%>