从函数内调用 Cufon.Replace 时出现问题
我正在做一个内容加载器,加载的内容需要一些 Cufon 操作。 现在这不起作用,因为我只在初始页面加载时应用 Cufon。而不是新加载的内容。
现在,这不应该起作用吗?
function loadContent() {
$('#content').load(toLoad,'',showNewContent())
Cufon.replace('h1, h2, h3, h4, .menuwrapper', { fontFamily: 'advent'});}
或者我没有得到什么? 我还尝试在调用 loadContent 函数的过程之后立即调用 Cufon.Replace,但这仅在我下次单击链接时应用 Cufon。
$('.dynload').live('click', function(){
var toLoad = $(this).attr('href')+' #content';
$('#content').fadeOut('fast',loadContent);
$('#ajaxloader').fadeIn('normal');
window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length);
Cufon.replace('h1, h2, h3, h4, .menuwrapper', { fontFamily: 'advent'});
如何确保加载新内容后尽快应用 Cufon?我正在考虑在新内容淡入之前调用 Cufon.replace 。但这似乎不起作用。
I'm doing a content loader and the content that gets loaded needs some Cufon action.
And that doesn't work right now since I only apply Cufon when the initial page loads. And not the newly loaded content.
Now, shouldn't this be working?
function loadContent() {
$('#content').load(toLoad,'',showNewContent())
Cufon.replace('h1, h2, h3, h4, .menuwrapper', { fontFamily: 'advent'});}
Or am I not getting something?
I've also tried calling Cufon.Replace right after the procedure that calls the loadContent function, but that only applies the Cufon the next time I click a link.
$('.dynload').live('click', function(){
var toLoad = $(this).attr('href')+' #content';
$('#content').fadeOut('fast',loadContent);
$('#ajaxloader').fadeIn('normal');
window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length);
Cufon.replace('h1, h2, h3, h4, .menuwrapper', { fontFamily: 'advent'});
How can I make sure Cufon is applied as soon as possible after loading new content? I was thinking about calling Cufon.replace the moment before the new content is faded in. But this doesn't seem to be working.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
load
函数可能是异步的,因此当您运行 Cufon 命令时内容还不会出现。您是否尝试在showNewContent()
函数末尾添加 cufon 替换? (我假设内容加载后会被调用)顺便说一句:如果您已经在页面加载时使用 cufon ,您可以/应该使用
Cufon.refresh()
重新应用替换而不是进行新的替换。The
load
function probably is asynchronous, so the content won't be there yet when you run the Cufon command. Did you try adding the cufon replace at the end of theshowNewContent()
function? (I'm assuming that will be called when the content has been loaded)BTW: if you already use cufon on page-load you could/should use
Cufon.refresh()
to re-apply the replace instead of doing a new replace.