【问题标题】:Reloading Cufon after Ajax load, please assistAjax加载后重新加载Cufon,请协助
【发布时间】:2011-06-02 21:11:06
【问题描述】:

我一直在尝试 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;

    });

});

这是我遇到问题的页面。 Climate Page 您将在页面底部看到带有二级菜单列表的 Ajax 加载器。 我很绝望,请帮助...

【问题讨论】:

    标签: ajax jquery cufon


    【解决方案1】:

    我遇到了同样的问题,为了更快地解决问题,我做了一个内联 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>
    

    【讨论】:

      【解决方案2】:

      这对我有用...

      $(document).ajaxSuccess(function() {  
          Cufon.refresh();
      });
      

      【讨论】:

        【解决方案3】:

        ajax 响应后你可以简单地使用

        Cufon.refresh();
        

        这将重新加载 cufon 字体样式

        【讨论】:

          【解决方案4】:
          $(document).ajaxSuccess(function() { Cufon.refresh(); });
          

          希望对你有帮助:)

          【讨论】:

            【解决方案5】:

            我遇到了同样的问题,无法让它工作:

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

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

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

            【讨论】:

            • 刚遇到这个问题,你的回答就成功了。我最初是按照你的方式尝试的。
            【解决方案6】:

            你可以试试这个:

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

            cufon api 文档中也对此进行了讨论 - https://github.com/sorccu/cufon/wiki/API

            【讨论】:

              【解决方案7】:

              尝试添加这个:

              $(document).ajaxSuccess(function() {  
              Cufon('h2'); // or whatever other cufon calls, really...
              });
              

              【讨论】:

                猜你喜欢
                • 1970-01-01
                • 2015-05-25
                • 2013-06-03
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 2014-06-23
                相关资源
                最近更新 更多