I\'m loading pages asynchronously with the jQuery load function, like this:
tree.click(function() {
if ($(this).hasClass(\"file\")) {
SyntaxHighlighter.all
ties into the window.onload
event - which only fires once.
To syntax-highlight after the page loads, use the highlight
function instead:
content.load("content/"+this.id+".html", function () {
// this is executed after the content is injected to the DOM
contentContainer.effect("highlight");
SyntaxHighlighter.highlight();
});
Fingers crossed that works, if not (based on looking at the code) you might need to chuck in some explicit arguments (where {}
is an empty set of configuration parameters, and this
will be content
when called from the ajax load handler):
SyntaxHighlighter.highlight({}, this);
You need to call that in the callback to load:
content.load("content/"+this.id+".html",function() {
SyntaxHighlighter.all();
});
load is asynchronous so it happily continues along executing statements while the GET request is done in the background.