简体   繁体   中英

Why can't I get to my $document Ready function

I am trying to pop a modal, I know this code works, but for some reason my js is either not loading or not getting to the $document.ready. I have an alert and I ran in debug mode and it isn't even firing.

here is my .aspx with the script to load the 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>

and here is my script:

(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;
});

You have defined the function within the closure, but never call it. Try this:

(function (window) {
    // your code...
})(window);

You are defining a function that never gets called. Since everything else hinges on this function running, nothing happens.

Invoke the function immediately after defining it to see some action:

(function (window) {
    /// your code here
})(window); // added (window) to invoke

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM