就绪函数未执行

发布于 2024-10-02 05:27:17 字数 449 浏览 10 评论 0原文

仅当我通过 firebug 添加断点并从那里继续或在行 var Buttons 之前发出警报时,才会执行 $(document).ready 。否则它什么也不做。

$(document).ready(function () {
    //alert('sdfsdf');
    var buttons = $(".modalInput").overlay({
        mask: {
            color: '#ebecff',
            loadSpeed: 200,
            opacity: 0.9
        },

        closeOnClick: false
    });
}); 

我使用 Mvc2 并使用 Telerik Components。

有什么建议吗?

$(document).ready will only be executed if I add a breakpoint via firebug and continue from there or an alert before the line var buttons. Otherwise it does nothing.

$(document).ready(function () {
    //alert('sdfsdf');
    var buttons = $(".modalInput").overlay({
        mask: {
            color: '#ebecff',
            loadSpeed: 200,
            opacity: 0.9
        },

        closeOnClick: false
    });
}); 

I work with Mvc2 and use Telerik Components.

Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

凹づ凸ル 2024-10-09 05:27:17

如果它在您发出警报和设置断点时起作用,那么听起来问题出在您的覆盖设置上,而不是就绪函数上。您可以发布一些正在处理的覆盖层的 HTML 代码吗?

If it works when you alert and when you set a breakpoint, it sounds like the problem is with your set up of the overlays and not with the ready function at all. Can you post some HTML code for the overlays are working on?

云巢 2024-10-09 05:27:17

具有“modalInput”的元素可能在窗口加载事件上发生自己的初始化代码,并且当您拥有自己的代码时,该代码尚未执行。

正确的解决方案是捕获这些元素的某种“完成”事件,也许 Telerik 组件会暴露这样的事情?

快速而肮脏的解决方案是使用计时器(window.setTimeout)并在文档准备好后一秒执行代码。

The elements with "modalInput" probably have their own initialization code occurring on window load event, and this code has not yet executed when you have your own code.

Correct solution will be to catch some sort of "Completed" event of those elements, maybe Telerik component expose such thing?

Quick and dirty solution will be to use timer (window.setTimeout) and have your code executed for example one second after the document is ready.

情定在深秋 2024-10-09 05:27:17

您是否在此脚本块之前包含 jquery-source ?

错误的是:

<script type="text/javascript">
    $(document).ready(function () {
        //alert('sdfsdf');
        var buttons = $(".modalInput").overlay({
            mask: {
                color: '#ebecff',
                loadSpeed: 200,
                opacity: 0.9
            },
            closeOnClick: false
        });
    }); 
</script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.js"></script>

而以下是正确的 顺便问

<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        //alert('sdfsdf');
        var buttons = $(".modalInput").overlay({
            mask: {
                color: '#ebecff',
                loadSpeed: 200,
                opacity: 0.9
            },
            closeOnClick: false
        });
    }); 
</script>

一下,你的警报有效吗?

Do you include the jquery-source before this script block?

Wrong would be:

<script type="text/javascript">
    $(document).ready(function () {
        //alert('sdfsdf');
        var buttons = $(".modalInput").overlay({
            mask: {
                color: '#ebecff',
                loadSpeed: 200,
                opacity: 0.9
            },
            closeOnClick: false
        });
    }); 
</script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.js"></script>

whereas following would be correct

<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        //alert('sdfsdf');
        var buttons = $(".modalInput").overlay({
            mask: {
                color: '#ebecff',
                loadSpeed: 200,
                opacity: 0.9
            },
            closeOnClick: false
        });
    }); 
</script>

By the way, does your alert work?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文