Infinite Scroll and SyntaxHighlighter Evolved

I like the idea of AJAX pagination whenever it makes sense (e.g. I'm not looking at tabulated data that I want to play with), and so it bugged me that I couldn't get SyntaxHighlighter Evolved and Infinite Scroll to behave nicely here. I tried a few months ago between meetings to force compliance to no avail. There is, what looked like, a simple recommendation here to change the callback after loading the next page from this:

1
SyntaxHighlighter.highlight(undefined,$('pre',this).get()); //didn't work for me<

...to this:

1
SyntaxHighlighter.highlight($('pre')); //also didn't work for me

That, however, did nothing. Not even an error in Firebug. I gave up, and way too quickly. Today, 6 months later, it took me all of 5 seconds to find my bug. Wordpress, by default, overwrites the $ function, so to use jQuery's namespace, you have to call it properly with jQuery instead:

1
SyntaxHighlighter.highlight(jQuery('pre')); //success!

There's taking a step back, and then there's completely forgetting about a problem. Both work, apparently.

Aug 19th, 2012

Comments