为什么没有定义插件函数但是正在加载js引用

时间:2014-11-20 11:30:00

标签: javascript jquery ajax

所以我使用的是第三方模态插件:来自Websanova.com的wModal.js

我的javascript库全部加载在我的文档底部。没关系。

问题在于:

<script type="text/javascript" src="js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="js/wModal/wModal.js"></script>
<script type="text/javascript" src="js/jquery-ui.js"></script>
<script type="text/javascript" src="js/jquery.simplyCountable.js"></script>
<script type="text/javascript" src="js/jquery.wysiwyg.js"></script>
<script type="text/javascript" src="js/jquery.hoverfold.js"></script>
<script type="text/javascript" src="js/bootstrap/bootstrap.js"></script>
<script type="text/javascript" src="js/bootstrap/bootstrapValidator.js"></script>
<script type="text/javascript" src="js/wysiwyg.image.js"></script>
<script type="text/javascript" src="js/wysiwyg.link.js"></script>
<script type="text/javascript" src="js/wysiwyg.table.js"></script>
<script type="text/javascript" src="js/modernizr.custom.69142.js"></script>
<script type="text/javascript">

    var elapsedTime = 0;
    var sessTimeout = "<%= Session.Timeout %>";
    sessTimeout = parseFloat(sessTimeout);
    // set to the Session.Timeout value to notify users
    // one minute after their Session times out.
    var maxTime = (sessTimeout + 1) * 60;
    var oneSecond;
    oneSecond = window.setTimeout("timeoutCheck();", 1000);
    var today = new Date();



    //Set the Copyright Date
    window.onload = function () {

        var myDate = today.getMonth() + 1 + "/" + today.getDate() + "/" + today.getFullYear();
        $("#cDate").html(today.getFullYear());

        var ftoday;
        ftoday = new Date();
        var myFDate = ftoday.getFullYear() + "." + (ftoday.getMonth() + 1) + "." + ftoday.getDate();
        $("#fCdate").html(ftoday.getFullYear());
        $("#fBdate").html(myFDate);
        $("#bYr").html(ftoday.getYear() + "." + ftoday.getDate());

    };



    $(document).ready(function () {

        //dynamically load Modals 
        $.get('includes/help-modal.html', function (data) {
            //Load the DIV with all the modals
            $('#templates').html(data);



            $('#wModal_info').wModal({
                position: 'cm', //This means: Center Middle
                offset: '5',
                fxShow: 'slideDown',
                fxHide: 'slideUp',
                btns: {
                    'ok': function () {
                        console.log('original info');
                        this.hide();
                        //...some other function can be called here
                    }
                }
            });
        });

        //This fires the MODAL HELP window
        $("#btnHelp").click(function () {
            $("#wModal_info").wModal('show'); <--THIS IS THE PROBLEM
        });
    });

    function timeoutCheck() {
        elapsedTime = elapsedTime + 1;
        if (elapsedTime > maxTime) {
            window.location = "youTimedOut.asp";
        }
        else {
            oneSecond;
        }
    }
    //This fakes a window so you can close a tab in the browser
    function tricky_win_close() {
        window.open('', '_self', '');
        window.close();
    }

    //Check where we are...
    var pageName = "<%= Session("current_page") %>"; //Don't worry, this works...not the problem
            if (pageName === "login") {

        $("#btnSubmit").on("click", function () {
            $("#username").val(function (i, val) {
                if (val === "") {
                    $('#warning').html("<font=red class=compname>Username Missing</font>");
                    return false;
                }
            });
            $("#password").val(function (i, val) {
                if (val === "") {
                    $('#warning').html("<font=red class=compname>Username Missing</font>");
                    return false;
                }
            });

            $("form1").submit();
        });
        $("#username").on("change", function () {
            $(this).val(function (i, val) {
                if (val !== "") {
                    $('#warning').html("");
                    return false;
                }
            });
        });
        $("#password").on("change", function () {
            $(this).val(function (i, val) {
                if (val !== "") {
                    $('#warning').html("");
                    return false;
                }
            });
        });
    }

</script>

因此,当我在浏览器中单击btnHelp时,对OPM wModal对话框的调用将失败,并显示:

Uncaught Typeerror:undefined不是函数。

实际上,只有加载页面才会出现错误,直到我点击&#34; btnHelp&#34;按钮。

我很困惑。我之前使用过这个... wModal.js就是这样。这里:  https://github.com/websanova/wModal#wmodaljs

我已将代码放在$(document).ready(function(){});内但无济于事......我已将其删除......

实例化活动&#34;生活&#34;在$.get('includes/help-modal.html', function (data) {....

任何帮助都将不胜感激。

由于

更新:所以这里是我的DEV CONSOLE在CHROME中的屏幕截图。

This is the Dev Console showing the error "AFTER" I click the btnHelp

希望这会有所帮助,因为我不知道它是如何定义的。

再次感谢

0 个答案:

没有答案