5

我一直在尝试 cufon.replace - Cufon.refresh 和 Cufon.reload 的所有可能组合,但我似乎无法让它工作。当原始页面加载时,cufon 完成了它的工作,但是当 Ajax 加载新内容时,cufon 丢失了。这是我的 java 希望这对任何人都有意义,Cufon 首先触发,然后是 Ajax,

    jQuery.noConflict();

/*
  * TYPOGRAPHY
*/

Cufon.set('fontFamily', 'ColaborateLight');
Cufon.replace('h2, #main h3, h4, h5, h6, #slogan, .label', {
    hover: true
});

Cufon.set('fontFamily', 'Colaborate-Medium');
Cufon.replace('#main_home h3', {
    hover: true
});

jQuery(document).ready(function() {

    var hash = window.location.hash.substr(1);
    var href = jQuery('#nav2 li a').each(function(){
        var href = jQuery(this).attr('href');
        if(hash==href.substr(0,href.length-5)){
            var toLoad = hash+'.html #content';
            jQuery('#content').load(toLoad)
        }                                           
    });

    jQuery('#nav2 li a').click(function(){
    jQuery("#nav2 li a").addClass("current").not(this).removeClass("current");

        var toLoad = jQuery(this).attr('href')+' #content';
        jQuery('#content').hide('fast',loadContent);
        jQuery('#load').remove();
        jQuery('#wrapper').append('<span id="load">LOADING...</span>');
        jQuery('#load').fadeIn('normal');
        window.location.hash = jQuery(this).attr('href').substr(0,jQuery(this).attr('href').length-5);
        function loadContent() {
            jQuery('#content').load(toLoad,'',showNewContent())
        }
        function showNewContent() {
            jQuery('#content').show('normal',hideLoader());
        }
        function hideLoader() {
            jQuery('#load').fadeOut('normal');
        }
        return false;

    });

});

这是我遇到问题的页面。 气候页面 您将在页面底部看到带有二级菜单列表的 Ajax 加载器。我很绝望,求各位大神帮忙...

4

7 回答 7

9

我有同样的问题,无法让它工作:

$("#my_div").load('some-ajax-file.php', Cufon.refresh);

但是,将 Cufon.refresh 包装在一个函数中就可以了:

$("#my_div").load('some-ajax-file.php', function() { Cufon.refresh(); });
于 2011-05-05T14:50:00.137 回答
5

这对我有用...

$(document).ajaxSuccess(function() {  
    Cufon.refresh();
});
于 2012-10-26T15:36:24.160 回答
2

你可以试试这个:

function showNewContent() {
    Cufon.refresh();
    jQuery('#content').show('normal',hideLoader());
}

这也在 cufon api 文档中讨论 - https://github.com/sorccu/cufon/wiki/API

于 2011-02-14T12:20:38.680 回答
1

ajax响应后,您可以简单地使用

Cufon.refresh();

这将重新加载 cufon 字体样式

于 2012-07-18T06:34:44.327 回答
0

尝试添加这个:

$(document).ajaxSuccess(function() {  
Cufon('h2'); // or whatever other cufon calls, really...
});
于 2011-01-10T16:45:01.340 回答
0
$(document).ajaxSuccess(function() { Cufon.refresh(); });

希望能帮助到你 :)

于 2012-05-21T14:28:05.257 回答
0

我有同样的问题,为了更快地解决问题,我做了一个内联 CSS

 <h5 style="font-family:xxx, Helvetica, sans-serif"></h5>

<style type="text/css">
  @font-face { 
    font-family: SWZ721C; 
    src: url('../../includedfiles/xxx.TTF');
  }

  @font-face {
    font-family: MyCustomFont;
    src: url("../../includedfiles/xxx.eot") /* EOT file for IE */
  }
</style>
于 2012-01-11T16:18:53.083 回答