Cufon refreshBrowser Info Environment
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?
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:
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.
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.
On 24/03/13 12:39, concrete5 Community wrote:
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.