1

我正在尝试弹出一个模式,我知道这段代码有效,但由于某种原因,我的 js 要么没有加载,要么没有到达 $document.ready。我有一个警报,我在调试模式下运行,它甚至没有触发。

这是我的 .aspx 与加载 js 的脚本

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RCC_ChgPassTester.aspx.cs" Inherits="Regal.Web._Tester.RCC.RCC_ChgPassTester" %>
<%@ Register Src="RCC_ChangePassword.ascx" TagPrefix="Rcc" TagName="RCCChgPass" %> 
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>

    <link href="/assets/css/home.css" media="all" rel="stylesheet" type="text/css"/> 
    <link href="/assets/css/modal.css" media="all" rel="stylesheet" type="text/css"/>
    <link href="/assets/css/rcc-main.css" media="all" rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" href="http://www.regmovies.com/assets/css/jquery-plugins.css"/>
 <!--   <link rel="stylesheet" href="/assets/css/global.css" /> -->  

    <script type="text/javascript" src="/assets/js/jquery.js"></script>
    <script type="text/javascript" src="/assets/js/jquery-plugins.js"></script>
    <script type="text/javascript" src="/assets/js/jquery.openCarousel.js"></script>
    <script type="text/javascript">
        /*<![CDATA[*/
        window.jQuery || document.write('<script type="text/javascript" src="/assets/js/jquery.js">\x3C/script>') /*]]>*/
    </script>
<script type="text/javascript" src="../_assets/js/RCCTester.js"></script>
</head>
<body id="body" style="background-image:url(http://www.regmovies.com/~/media/Images/Site%20Takeovers/wallpaper_cloudyNP.ashx);">


    <form id="form1" runat="server">
    <div>         
    <RCC:RCCChgPass runat="server" ID="ChgPass" />
    </div>
    </form>

</body>
</html>

这是我的脚本:

(function (window) {
    var
   $ = window.jQuery,
   modalLocation = '#modal-password-change',
    modalPasswordChangeOpts = {
        autoOpen: true,
        modal: true,
        resizable: false,
        draggable: false,
        width: '450',
        height: '550',
        dialogClass: 'modal',
        close: function () { $(this).dialog('destroy'); }
    };

    function showModal() {
        $(modalLocation).dialog($.extend(modalPasswordChangeOpts))
        $(modalLocation).dialog('open');
    }

    $(document).ready(function () {

        RCC.showModal();
        alert("I am here");
        return false;
    });


    window.RCC = window.RCC || {};
    window.RCC.showModal = showModal;
});
4

2 回答 2

3

您已经在闭包中定义了函数,但从不调用它。尝试这个:

(function (window) {
    // your code...
})(window);
于 2013-11-02T22:59:27.130 回答
2

您正在定义一个永远不会被调用的函数。由于其他一切都取决于此功能的运行,因此没有任何反应。

定义后立即调用该函数以查看一些操作:

(function (window) {
    /// your code here
})(window); // added (window) to invoke
于 2013-11-02T22:58:57.907 回答