Tuesday, March 01, 2011

Cufon and lightbox timing issues

I ran into a problem where I ran Cufon on page load using JQuery which worked fine. The website also has lightboxes using jqModal. These lighboxes get loaded in using AJAX.

Problem:
The Cufon script does not replace the text to use custom fonts when showing the lightbox.

Solution:
Cufon needs to run after displaying the lightbox. Running it as a callback function for an onShow event also does not seem to work. Running Cufon manually from an onclick event on the lightbox itself does work, which means there is a timing issue involved. Hopefully this helps whoever else has got this same problem.