Cufon refresh

Permalink Browser Info Environment
Hi,

I've created a content block using the AJAX load template, and I've set up Cufon to replace the H2 font. Without the AJAX load it works, but with the AJAX load it does not. I've tried putting in some script to manage a cufon refresh because I read online that Cufon needs to be refreshed after an AJAX call but still no luck. Any ideas?

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

Type: Discussion
Status: New
View Replies: View Best Answer
JohntheFish replied on at Permalink Reply
JohntheFish
Without seeing the entire block view and controller, it is hard to be sure.

First, try putting a console.log() statement into the ajax success handler so you can see if it is firing. Because the loaded content is not evaluated until after the ajax has completed, I suspect that the event handler will not be attached until after the event has been and gone, so your handler would never fire.

I usually just put script that is inside an ajax loaded view into a document ready handler, because jQuery then runs that as soon as the load is completed (and it is identical for non-ajax temnplates).

So my second suggestion is to change it to a straight forward document ready handler.

If that does not fire, then my third suggestion is to change it to a self executing closure function (with no jquery event).

In both cases, use a console.log() to get some debug/trace info, then remove it when working OK.

As long as that loads with the ajaxed block content, it will then be evaluated as soon as the ajaxed content has loaded.

You may find this howto of interest:
http://www.concrete5.org/documentation/how-tos/developers/some-tric...
McArtney82 replied on at Permalink Reply
Thanks mate, I'll give it a shot and let you know how I go
McArtney82 replied on at Permalink Reply
Ok so first thanks for pointing me to the console log tutorial, very helpful. The log fired on the $(document).ajaxSuccess and still not cufon refresh. I then tried to put the Cufon.refresh() in my $(document).ready (the log fired ok so it reached there) but still no good.

I'm going to keep looking into it but any other ideas / suggestions you might have would be greatly appreciated. If you need to see my code just let me know, it's quite large build so the code is rather long.
JohntheFish replied on at Permalink Reply
JohntheFish
Its good that the events are firing.

The call to Cufon.refresh() may actually load a file or make a network
request (Having never used cufon I am not sure of that), so have a look
at the network tab of the developer console and see if it does on a
regular page load. If it does, then the next step is to check it is also
happening after the ajax call completes. So maybe you you can see first
an ajax load made by blocks by ajax, then Cufon.refresh() making a
network request after the ajax has completed.

John



On 24/03/13 12:39, concrete5 Community wrote:
McArtney82 replied on at Permalink Best Answer Reply
Hi Mr Fish,

I've worked it out, I was hiding div's using the CSS visibility property, found out that cufon has some bugs using that so it really had nothing to do with the AJAX load.

Appreciate your help on this and now I've learned a cool new way to debug my javascript, so that's a win :)

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.