Using Prism.js with AJAX content
June 03, 2014
I’m using Prism for code highlighting. And, this blog theme uses AJAX to fetch and transition pages (or show/hide the recent posts). Those two things did not work well together.
The issue is that Prism wasn’t triggered to add its markup after a page transitioned; leaving me with a horribly-styled code block.
The fix, as outlined on the Prism documentation is straightforward. You can tell it to manually render:
I added this to the end of the $.get AJAX call and all is right with the world again.