使用 jquery.fade() 回调时加载内容的 Dd_belatedPng 问题
我正在使用 jquery 通过 ajax 将一些 html 加载到 div 中。加载内容后,我需要使用 DD_belatedPNG 修复 ie6 的 png。下面的代码 -
$("#content").fadeOut(function(){
$(this).html("<div><p>some text</p><img src='myimage.png' class='dayPosted' /><p>some more text</p></div>").fadeIn( fixIeIssue() ); //The html in this function is for example only, in my app it's populated by ajax.
})
fixIeIssue = function(){
if (window.DD_belatedPNG){
//alert("for some reason this works if I call an alert here")
DD_belatedPNG.fix('.dayPosted');
}
}
png 修复不起作用。奇怪的是,如果我在调用修复之前调用警报,它确实有效。
我尝试将 document.ready 添加到 fixIeIssue 中,但这没有帮助。
png 修复确实适用于初始页面加载。
I'm loading some some html into a div through ajax using jquery. Once the content is loaded, I need to fix pngs for ie6, using DD_belatedPNG. Code below -
$("#content").fadeOut(function(){
$(this).html("<div><p>some text</p><img src='myimage.png' class='dayPosted' /><p>some more text</p></div>").fadeIn( fixIeIssue() ); //The html in this function is for example only, in my app it's populated by ajax.
})
fixIeIssue = function(){
if (window.DD_belatedPNG){
//alert("for some reason this works if I call an alert here")
DD_belatedPNG.fix('.dayPosted');
}
}
The png fix is not working. Oddly, it does work if I call an alert before calling the fix.
I've tried adding a document.ready into the fixIeIssue but that didn't help.
The png fix does work on the initial page load.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将函数作为参数传递。您还忘记了 fadeIn() 的第一个参数。尝试:
如果
fixIeIssue()
返回一个函数,您的版本就可以工作,但事实并非如此。Pass function as argument. You also forget about 1st argument of fadeIn(). Try:
Your version would work if
fixIeIssue()
will return a function, but it doesn't.