Reloading Cufon after Ajax load, please assist

Christo Van Wyk picture Christo Van Wyk · Jan 3, 2011 · Viewed 7.3k times · Source

I have been trying every possible combination of cufon.replace - Cufon.refresh and Cufon.reload but i just cant seem to get this working. when original page loads cufon does its job, but when Ajax loads new content the cufon is missing. here is my java hope this makes sense to anyone, Cufon fires first, followed by 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;

    });

});

and this is the pages in question that im having trouble with. Climate Page You will see the Ajax loader at the bottom of the page with a secondary menu list. I'm desperate guys, please help...

Answer

jbnunn picture jbnunn · May 5, 2011

I had the same issue, couldn't get this to work:

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

But, wrapping Cufon.refresh in a function did the trick:

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