就绪函数未执行
仅当我通过 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果它在您发出警报和设置断点时起作用,那么听起来问题出在您的覆盖设置上,而不是就绪函数上。您可以发布一些正在处理的覆盖层的 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?
具有“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.
您是否在此脚本块之前包含 jquery-source ?
错误的是:
而以下是正确的 顺便问
一下,你的警报有效吗?
Do you include the jquery-source before this script block?
Wrong would be:
whereas following would be correct
By the way, does your alert work?